public enum DurationFormat extends Enum<DurationFormat>
Examples:
0:00:03.2000000003.200000000 second(s)3.2 second(s)PT3.2S0m3.200s| 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.
|
LINUX
Formats a time duration in Linux style, applying the form
M'm':S.ms's'. |
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 |
|---|---|
String |
format(Duration duration,
boolean printLegend)
Formats a given duration.
|
Duration |
parse(String string)
Parses a textual representation of a
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.987654321.public 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
For example: 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
secondsAdditional examples:
PT0.001SPT3.2SPT15M0.00589S
Note: The printLegend flag has no effect in this format style.
public static final DurationFormat LINUX
M'm':S.ms's'.
Examples:
0m0.125s0m4.999s3m12.038s
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 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 nullpublic Duration parse(String string)
Duration.string - the string to parse, not nullDuration, not nullNullPointerException - if the specified string is nullIllegalArgumentException - if the string cannot be parsed as DurationCopyright © 2023. All rights reserved.