public enum DurationFormat extends Enum<DurationFormat>
Examples:
0:00:03.2000000003.200000000 second(s)3.2 second(s)PT3.2S| Enum Constant and Description |
|---|
FULL
Formats a time duration in the following format:
H:M:s:ns. |
ISO_8601
Formats a time duration using ISO-8601 seconds based representation, such as
PT8H6M12.345S, where:
P is the duration designator (referred to as "period"), and is always
placed at the beginning of the duration
T is the time designator that precedes the time components
H is the hour designator that follows the value for the number of hours
M is the minute designator that follows the value for the number of
minutes
S is the second designator that follows the value for the number of
seconds
Examples:
PT0.001S
PT3.2S
PT15M0.00589S
Note: The printLegend flag has no effect in this format style. |
SHORT
Formats a time duration in any of the following formats:
H:M:s:ns,
M:S:ns, or S.ns, always choosing the shortest possible format. |
SHORTER
Formats a time duration in any of the following formats:
H:M:s:ns,
M:S:ns, or S.ns, always choosing the shortest possible format and
suppressing trailing zeros from the nanoseconds part. |
| Modifier and Type | Method and Description |
|---|---|
abstract String |
format(Duration duration,
boolean printLegend)
Formats a given duration.
|
static DurationFormat |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static DurationFormat[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final DurationFormat FULL
H:M:s:ns. For example:
1:59:59.987654321public static final DurationFormat SHORT
H:M:s:ns,
M:S:ns, or S.ns, always choosing the shortest possible format.
Examples:
0.001000000 second(s)3.200000000 second(s)15:00.005890000 minute(s)public static final DurationFormat SHORTER
H:M:s:ns,
M:S:ns, or S.ns, always choosing the shortest possible format and
suppressing trailing zeros from the nanoseconds part.
Examples:
0.001 second(s)3.2 second(s)15:00.00589 minute(s)public static final DurationFormat ISO_8601
PT8H6M12.345S, where:
P is the duration designator (referred to as "period"), and is always
placed at the beginning of the durationT is the time designator that precedes the time componentsH is the hour designator that follows the value for the number of hours
M is the minute designator that follows the value for the number of
minutesS is the second designator that follows the value for the number of
secondsExamples:
PT0.001SPT3.2SPT15M0.00589S
Note: The printLegend flag has no effect in this format style.
public static DurationFormat[] values()
for (DurationFormat c : DurationFormat.values()) System.out.println(c);
public static DurationFormat valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic abstract String format(Duration duration, boolean printLegend)
duration - the Duration to be formatted, not nullprintLegend - a flag indicating whether or not to include the legend in the
generated stringNullPointerException - if the specified Duration is nullCopyright © 2021. All rights reserved.