public enum ClockUnit extends Enum<ClockUnit> implements IsoTimeUnit
Represents the most common time units on an ISO-8601-conforming analogue clock counting the scale ticks.
| Enum Constant and Description |
|---|
HOURS
Time unit "hours" (symbol H)
|
MICROS
Time unit "microseconds" (symbol 6)
|
MILLIS
Time unit "milliseconds" (symbol 3)
|
MINUTES
Time unit "minutes" (symbol M)
|
NANOS
Time unit "nanoseconds" (symbol 9)
|
SECONDS
Time unit "seconds" (symbol S) according to the
position of the second pointer on an analogue clock.
|
| Modifier and Type | Method and Description |
|---|---|
<T extends TimePoint<? super ClockUnit,T>> |
between(T start,
T end)
Calculates the temporal distance between given wall times
in this unit.
|
long |
convert(long sourceDuration,
ClockUnit sourceUnit)
Converts the given duration to a temporal amount measured in
this unit.
|
long |
convert(TimeSpan<? extends ClockUnit> duration)
Converts the given duration to an amount in this unit and performs
any necessary truncation if needed.
|
boolean |
isCalendrical()
A wall time unit is never calendrical.
|
Normalizer<ClockUnit> |
only()
Yields a normalizer which converts a given duration in another
duration with only this clock unit.
|
Normalizer<ClockUnit> |
rounded()
Yields a normalizer which converts a given duration in another
normalized duration with smaller units truncated and this unit rounded.
|
Normalizer<ClockUnit> |
truncated()
Yields a normalizer which converts a given duration in another
duration with smaller units truncated.
|
static ClockUnit |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static ClockUnit[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOfgetLengthpublic static final ClockUnit HOURS
public static final ClockUnit MINUTES
public static final ClockUnit 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.
SIpublic static final ClockUnit MILLIS
public static final ClockUnit MICROS
public static final ClockUnit NANOS
public static ClockUnit[] values()
for (ClockUnit c : ClockUnit.values()) System.out.println(c);
public static ClockUnit 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 <T extends TimePoint<? super ClockUnit,T>> long between(T start, T end)
Calculates the temporal distance between given wall times in this unit.
T - generic type of time pointstart - starting timeend - ending timepublic long convert(long sourceDuration,
ClockUnit sourceUnit)
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 to 0 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.
sourceDuration - amount of duration to be convertedsourceUnit - time unit of duration to be convertedArithmeticException - in case of long overflowpublic long convert(TimeSpan<? extends ClockUnit> duration)
Converts the given duration to an amount in this unit and performs any necessary truncation if needed.
duration - temporal amount in clock units to be convertedpublic Normalizer<ClockUnit> only()
Yields a normalizer which converts a given duration in another duration with only this clock unit.
convert(TimeSpan)public Normalizer<ClockUnit> truncated()
Yields a normalizer which converts a given duration in another duration with smaller units truncated.
public Normalizer<ClockUnit> 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
Duration.STD_CLOCK_PERIODpublic boolean isCalendrical()
A wall time unit is never calendrical.
isCalendrical in interface ChronoUnitfalseCopyright © 2014–2015. All rights reserved.