public enum DurationFormat extends Enum<DurationFormat>
Examples:
| DurationFormat.SHORTER: | 3.2 second(s) |
| DurationFormat.SHORT: | 3.200000000 second(s) |
| DurationFormat.FULL: | 0:00:03.200000000 |
| DurationFormat.ISO_8601: | 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. |
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.
Examples:
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 formattedprintLegend - a flag indicating whether or not to include the legend in the
generated stringCopyright © 2021. All rights reserved.