org.apache.commons.lang.time
public class DurationFormatUtils extends Object
Duration formatting utilities and constants. The following table describes the tokens used in the pattern language for formatting.
character | duration element |
---|---|
y | years |
M | months |
d | days |
H | hours |
m | minutes |
s | seconds |
S | milliseconds |
Since: 2.1
Version: $Id: DurationFormatUtils.java 165657 2005-05-02 18:31:49Z ggregory $
Field Summary | |
---|---|
static String | ISO_EXTENDED_FORMAT_PATTERN Pattern used with |
Constructor Summary | |
---|---|
DurationFormatUtils() DurationFormatUtils instances should NOT be constructed in standard programming. This constructor is public to permit tools that require a JavaBean instance to operate. |
Method Summary | |
---|---|
static String | formatDuration(long durationMillis, String format) Get the time gap as a string, using the specified format, and padding with zeros and using the default timezone. This method formats durations using the days and lower fields of the format pattern. |
static String | formatDuration(long durationMillis, String format, boolean padWithZeros) Get the time gap as a string, using the specified format. |
static String | formatDurationHMS(long durationMillis) Get the time gap as a string. The format used is ISO8601-like: H:m:s.S. |
static String | formatDurationISO(long durationMillis) Get the time gap as a string. The format used is the ISO8601 period format. This method formats durations using the days and lower fields of the ISO format pattern, such as P7D6H5M4.321S. |
static String | formatDurationWords(long durationMillis, boolean suppressLeadingZeroElements, boolean suppressTrailingZeroElements) Format an elapsed time into a plurialization correct string. This method formats durations using the days and lower fields of the format pattern. |
static String | formatPeriod(long startMillis, long endMillis, String format) Get the time gap as a string, using the specified format. |
static String | formatPeriod(long startMillis, long endMillis, String format, boolean padWithZeros, TimeZone timezone) Get the time gap as a string, using the specified format. |
static String | formatPeriodISO(long startMillis, long endMillis) Get the time gap as a string. The format used is the ISO8601 period format. |
Pattern used with FastDateFormat
and SimpleDateFormat
for the ISO8601 period format used in durations.
See Also: FastDateFormat java.text.SimpleDateFormat
DurationFormatUtils instances should NOT be constructed in standard programming.
This constructor is public to permit tools that require a JavaBean instance to operate.
Get the time gap as a string, using the specified format, and padding with zeros and using the default timezone.
This method formats durations using the days and lower fields of the format pattern. Months and larger are not used.
Parameters: durationMillis the duration to format format the way in which to format the duration
Returns: the time as a String
Get the time gap as a string, using the specified format. Padding the left hand side of numbers with zeroes is optional and the timezone may be specified.
This method formats durations using the days and lower fields of the format pattern. Months and larger are not used.
Parameters: durationMillis the duration to format format the way in which to format the duration padWithZeros whether to pad the left hand side of numbers with 0's
Returns: the time as a String
Get the time gap as a string.
The format used is ISO8601-like: H:m:s.S.
Parameters: durationMillis the duration to format
Returns: the time as a String
Get the time gap as a string.
The format used is the ISO8601 period format.
This method formats durations using the days and lower fields of the ISO format pattern, such as P7D6H5M4.321S.
Parameters: durationMillis the duration to format
Returns: the time as a String
Format an elapsed time into a plurialization correct string.
This method formats durations using the days and lower fields of the format pattern. Months and larger are not used.
Parameters: durationMillis the elapsed time to report in milliseconds suppressLeadingZeroElements suppresses leading 0 elements suppressTrailingZeroElements suppresses trailing 0 elements
Returns: the formatted text in days/hours/minutes/seconds
Get the time gap as a string, using the specified format. Padding the left hand side of numbers with zeroes is optional.
Parameters: startMillis the start of the duration endMillis the end of the duration format the way in which to format the duration
Returns: the time as a String
Get the time gap as a string, using the specified format. Padding the left hand side of numbers with zeroes is optional and the timezone may be specified.
Parameters: startMillis the start of the duration endMillis the end of the duration format the way in which to format the duration padWithZeros whether to pad the left hand side of numbers with 0's timezone the millis are defined in
Returns: the time as a String
Get the time gap as a string.
The format used is the ISO8601 period format.
Parameters: startMillis the start of the duration to format endMillis the end of the duration to format
Returns: the time as a String