|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.lang.time.DurationFormatUtils
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 |
Field Summary | |
static java.lang.String |
ISO_EXTENDED_FORMAT_PATTERN
Pattern used with FastDateFormat and SimpleDateFormat
for the ISO8601 period format used in durations. |
Constructor Summary | |
DurationFormatUtils()
DurationFormatUtils instances should NOT be constructed in standard programming. |
Method Summary | |
static java.lang.String |
formatDuration(long durationMillis,
java.lang.String format)
Get the time gap as a string, using the specified format, and padding with zeros and using the default timezone. |
static java.lang.String |
formatDuration(long durationMillis,
java.lang.String format,
boolean padWithZeros)
Get the time gap as a string, using the specified format. |
static java.lang.String |
formatDurationHMS(long durationMillis)
Get the time gap as a string. |
static java.lang.String |
formatDurationISO(long durationMillis)
Get the time gap as a string. |
static java.lang.String |
formatDurationWords(long durationMillis,
boolean suppressLeadingZeroElements,
boolean suppressTrailingZeroElements)
Format an elapsed time into a plurialization correct string. |
static java.lang.String |
formatPeriod(long startMillis,
long endMillis,
java.lang.String format)
Get the time gap as a string, using the specified format. |
static java.lang.String |
formatPeriod(long startMillis,
long endMillis,
java.lang.String format,
boolean padWithZeros,
java.util.TimeZone timezone)
Get the time gap as a string, using the specified format. |
static java.lang.String |
formatPeriodISO(long startMillis,
long endMillis)
Get the time gap as a string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String ISO_EXTENDED_FORMAT_PATTERN
Pattern used with FastDateFormat
and SimpleDateFormat
for the ISO8601 period format used in durations.
FastDateFormat
,
SimpleDateFormat
,
Constant Field ValuesConstructor Detail |
public 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 Detail |
public static java.lang.String formatDurationHMS(long durationMillis)
Get the time gap as a string.
The format used is ISO8601-like: H:m:s.S.
durationMillis
- the duration to format
public static java.lang.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.
durationMillis
- the duration to format
public static java.lang.String formatDuration(long durationMillis, java.lang.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. Months and larger are not used.
durationMillis
- the duration to formatformat
- the way in which to format the duration
public static java.lang.String formatDuration(long durationMillis, java.lang.String format, boolean padWithZeros)
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.
durationMillis
- the duration to formatformat
- the way in which to format the durationpadWithZeros
- whether to pad the left hand side of numbers with 0's
public static java.lang.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. Months and larger are not used.
durationMillis
- the elapsed time to report in millisecondssuppressLeadingZeroElements
- suppresses leading 0 elementssuppressTrailingZeroElements
- suppresses trailing 0 elements
public static java.lang.String formatPeriodISO(long startMillis, long endMillis)
Get the time gap as a string.
The format used is the ISO8601 period format.
startMillis
- the start of the duration to formatendMillis
- the end of the duration to format
public static java.lang.String formatPeriod(long startMillis, long endMillis, java.lang.String format)
Get the time gap as a string, using the specified format. Padding the left hand side of numbers with zeroes is optional.
startMillis
- the start of the durationendMillis
- the end of the durationformat
- the way in which to format the duration
public static java.lang.String formatPeriod(long startMillis, long endMillis, java.lang.String format, boolean padWithZeros, java.util.TimeZone timezone)
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.
startMillis
- the start of the durationendMillis
- the end of the durationformat
- the way in which to format the durationpadWithZeros
- whether to pad the left hand side of numbers with 0'stimezone
- the millis are defined in
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |