Enum Class DurationFormat.Style
- All Implemented Interfaces:
Serializable
,Comparable<DurationFormat.Style>
,Constable
- Enclosing class:
- DurationFormat
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic DurationFormat.Style
Returns the enum constant of this class with the specified name.static DurationFormat.Style[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
SIMPLE
Simple formatting based on a short suffix, for example '1s'.Supported unit suffixes include:
ns, us, ms, s, m, h, d
. Those correspond to nanoseconds, microseconds, milliseconds, seconds, minutes, hours, and days, respectively.Note that when printing a
Duration
, this style can be lossy if the selected unit is bigger than the resolution of the duration. For example,Duration.ofMillis(5).plusNanos(1234)
would get truncated to"5ms"
when printing usingChronoUnit.MILLIS
.Fractional durations are not supported.
-
ISO8601
ISO-8601 formatting.This is what the JDK uses in
Duration.parse(CharSequence)
andDuration.toString()
. -
COMPOSITE
LikeSIMPLE
, but allows multiple segments ordered from largest-to-smallest units of time, like1h12m27s
.A single minus sign (
-
) is allowed to indicate the whole duration is negative. Spaces are allowed between segments, and a negative duration with spaced segments can optionally be surrounded by parentheses after the minus sign, like so:-(34m 57s)
.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-