Enum Class ClockUnit
- All Implemented Interfaces:
Serializable
,Comparable<ClockUnit>
,java.lang.constant.Constable
,ChronoUnit
,IsoTimeUnit
,IsoUnit
Represents the most common time units on an ISO-8601-conforming analogue clock counting the scale ticks.
- Author:
- Meno Hochschild
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionTime unit "hours" (symbol H)Time unit "microseconds" (symbol 6)Time unit "milliseconds" (symbol 3)Time unit "minutes" (symbol M)Time unit "nanoseconds" (symbol 9)Time unit "seconds" (symbol S) according to the position of the second pointer on an analogue clock. -
Method Summary
Modifier and TypeMethodDescriptionbetween(T start, T end)
Calculates the temporal distance between given wall times in this unit.long
Converts the given duration to a temporal amount measured in this unit.long
Converts the given duration to an amount in this unit and performs any necessary truncation if needed.boolean
A wall time unit is never calendrical.only()
Yields a normalizer which converts a given duration in another duration with only this clock unit.rounded()
Yields a normalizer which converts a given duration in another normalized duration with smaller units truncated and this unit rounded.Yields a normalizer which converts a given duration in another duration with smaller units truncated.static ClockUnit
Returns the enum constant of this class with the specified name.static ClockUnit[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
Methods inherited from interface net.time4j.engine.ChronoUnit
getLength
-
Enum Constant Details
-
HOURS
Time unit "hours" (symbol H) -
MINUTES
Time unit "minutes" (symbol M) -
SECONDS
Time unit "seconds" (symbol S) according to the position of the second pointer on an analogue clock.
This unit is NOT the SI-second.
- See Also:
SI
-
MILLIS
Time unit "milliseconds" (symbol 3) -
MICROS
Time unit "microseconds" (symbol 6) -
NANOS
Time unit "nanoseconds" (symbol 9)
-
-
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
-
between
Calculates the temporal distance between given wall times in this unit.
- Type Parameters:
T
- generic type of time point- Parameters:
start
- starting timeend
- ending time- Returns:
- duration as count of this unit
-
convert
Converts the given duration to a temporal amount measured in this unit.
Conversions from more precise to less precise units are usually associated with a loss of information. For example the conversion of
999
milliseconds results to0
seconds. In reverse, the conversion of less precise to more precise units can result in a numerical overflow.Example: In order to convert 44 minutes to milliseconds, the expression
ClockUnit.MILLIS.convert(44L, ClockUnit.MINUTES)
is applied. Note: If hours or minutes are to be converted then UTC-leapseconds will be ignored that is a minute has here always 60 seconds.- Parameters:
sourceDuration
- amount of duration to be convertedsourceUnit
- time unit of duration to be converted- Returns:
- converted duration expressed in this unit
- Throws:
ArithmeticException
- in case of long overflow
-
convert
Converts the given duration to an amount in this unit and performs any necessary truncation if needed.
- Parameters:
duration
- temporal amount in clock units to be converted- Returns:
- count of this unit representing given duration
- Since:
- 1.2
-
only
Yields a normalizer which converts a given duration in another duration with only this clock unit.
- Returns:
- normalizer
- Since:
- 1.2
- See Also:
convert(TimeSpan)
-
truncated
Yields a normalizer which converts a given duration in another duration with smaller units truncated.
- Returns:
- normalizer
- Since:
- 3.0
- See Also:
Duration.truncatedTo(IsoUnit)
-
rounded
Yields a normalizer which converts a given duration in another normalized duration with smaller units truncated and this unit rounded.
This normalizer is a combination of
Duration.STD_CLOCK_PERIOD
,truncated()
and a special half-up rounding. Example:Duration<ClockUnit> timePeriod = Duration.ofClockUnits(4, 55, 90); System.out.println(timePeriod.with(ClockUnit.MINUTES.rounded())); // output: P4H57M
- Returns:
- normalizer
- Since:
- 3.0
- See Also:
Duration.STD_CLOCK_PERIOD
-
isCalendrical
public boolean isCalendrical()A wall time unit is never calendrical.
- Specified by:
isCalendrical
in interfaceChronoUnit
- Returns:
false
-