Enum Class DurationFormat.Unit
- All Implemented Interfaces:
- Serializable,- Comparable<DurationFormat.Unit>,- Constable
- Enclosing class:
- DurationFormat
Duration format unit, which mirrors a subset of ChronoUnit and
 allows conversion to and from a supported ChronoUnit as well as
 conversion from durations to longs.
 The enum includes its corresponding suffix in the SIMPLE
 Duration format style.
- 
Nested Class SummaryNested classes/interfaces inherited from class java.lang.EnumEnum.EnumDesc<E extends Enum<E>>
- 
Enum Constant SummaryEnum Constants
- 
Method SummaryModifier and TypeMethodDescriptionConvert thisUnitto itsChronoUnitequivalent.asSuffix()static DurationFormat.UnitfromChronoUnit(@Nullable ChronoUnit chronoUnit) Get theDurationFormat.Unitcorresponding to the givenChronoUnit.static DurationFormat.UnitfromSuffix(String suffix) Get theDurationFormat.Unitcorresponding to the givenStringsuffix.longConvert the givenDurationto a long value in the resolution of this unit.Print the givenDurationas aString, converting it to a long value using this unit's precision vialongValue(Duration)and appending this unit's simplesuffix.static DurationFormat.UnitReturns the enum constant of this class with the specified name.static DurationFormat.Unit[]values()Returns an array containing the constants of this enum class, in the order they are declared.
- 
Enum Constant Details- 
NANOSNanoseconds ("ns").
- 
MICROSMicroseconds ("us").
- 
MILLISMilliseconds ("ms").
- 
SECONDSSeconds ("s").
- 
MINUTESMinutes ("m").
- 
HOURSHours ("h").
- 
DAYSDays ("d").
 
- 
- 
Method Details- 
valuesReturns 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
 
- 
valueOfReturns 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 name
- NullPointerException- if the argument is null
 
- 
asChronoUnitConvert thisUnitto itsChronoUnitequivalent.
- 
asSuffix
- 
parse- Parameters:
- value- the- Stringrepresentation of the long
- Returns:
- the corresponding Duration
 
- 
printPrint the givenDurationas aString, converting it to a long value using this unit's precision vialongValue(Duration)and appending this unit's simplesuffix.- Parameters:
- value- the- Durationto convert to a- String
- Returns:
- the Stringrepresentation of theDurationin theSIMPLEstyle
 
- 
longValueConvert the givenDurationto a long value in the resolution of this unit.Note that this can be lossy if the current unit is bigger than the actual resolution of the duration. For example, Duration.ofMillis(5).plusNanos(1234)would get truncated to5for unitMILLIS.- Parameters:
- value- the- Durationto convert to a long
- Returns:
- the long value for the Durationin thisUnit
 
- 
fromChronoUnitGet theDurationFormat.Unitcorresponding to the givenChronoUnit.- Throws:
- IllegalArgumentException- if the given- ChronoUnitis not supported
 
- 
fromSuffixGet theDurationFormat.Unitcorresponding to the givenStringsuffix.- Throws:
- IllegalArgumentException- if the given suffix is not supported
 
 
-