- All Implemented Interfaces:
Serializable
,Comparable<SimpleUnit>
,TemporalUnit
public enum SimpleUnit extends Enum<SimpleUnit> implements TemporalUnit
A custom temporal unit used for showing numbered units (1, 2, 3, ... or 10,
20, 30, ...).
-
Enum Constant Summary
Enum Constants Enum Constant Description BILLION
A granularity representing one billion milliseconds.BILLION_HUNDRED
A granularity representing one hundred billion milliseconds.BILLION_TEN
A granularity representing ten billion milliseconds.HUNDRED
A granularity representing one hundred milliseconds.MILLION
A granularity representing one million milliseconds.MILLION_HUNDRED
A granularity representing one hundred million milliseconds.MILLION_TEN
A granularity representing ten million milliseconds.ONE
A granularity representing one millisecond.TEN
A granularity representing ten milliseconds.THOUSAND
A granularity representing one thousand milliseconds.THOUSAND_HUNDRED
A granularity representing one hundred thousand milliseconds.THOUSAND_TEN
A granularity representing ten thousand milliseconds.TRILLION
A granularity representing one trillion milliseconds. -
Method Summary
Modifier and Type Method Description <R extends Temporal>
RaddTo(R temporal, long periodToAdd)
long
between(Temporal t1, Temporal t2)
long
decrement(long time)
Decrements the given number of milliseconds with the milliseconds represented by the enumerator value.Duration
getDuration()
long
getMillis()
Returns the number of milliseconds represented by the granularity.long
increment(long time)
Increments the given number of milliseconds with the milliseconds represented by the enumerator value.boolean
isDateBased()
boolean
isDurationEstimated()
boolean
isSupportedBy(Temporal temporal)
boolean
isTimeBased()
long
truncate(long time)
Truncates the given time point by rounding it down to the nearest multitude of the milliseconds represented by the granularity value.static SimpleUnit
valueOf(String name)
Returns the enum constant of this type with the specified name.static SimpleUnit[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
Methods inherited from interface java.time.temporal.TemporalUnit
toString
-
Enum Constant Details
-
ONE
A granularity representing one millisecond.- Since:
- 1.0
-
TEN
A granularity representing ten milliseconds.- Since:
- 1.0
-
HUNDRED
A granularity representing one hundred milliseconds.- Since:
- 1.0
-
THOUSAND
A granularity representing one thousand milliseconds.- Since:
- 1.0
-
THOUSAND_TEN
A granularity representing ten thousand milliseconds.- Since:
- 1.0
-
THOUSAND_HUNDRED
A granularity representing one hundred thousand milliseconds.- Since:
- 1.0
-
MILLION
A granularity representing one million milliseconds.- Since:
- 1.0
-
MILLION_TEN
A granularity representing ten million milliseconds.- Since:
- 1.0
-
MILLION_HUNDRED
A granularity representing one hundred million milliseconds.- Since:
- 1.0
-
BILLION
A granularity representing one billion milliseconds.- Since:
- 1.0
-
BILLION_TEN
A granularity representing ten billion milliseconds.- Since:
- 1.0
-
BILLION_HUNDRED
A granularity representing one hundred billion milliseconds.- Since:
- 1.0
-
TRILLION
A granularity representing one trillion milliseconds.- Since:
- 1.0
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified nameNullPointerException
- if the argument is null
-
increment
public long increment(long time)Increments the given number of milliseconds with the milliseconds represented by the enumerator value.- Parameters:
time
- the time to increment- Returns:
- the given time plus the milliseconds represented by the value
- Since:
- 1.0
-
decrement
public long decrement(long time)Decrements the given number of milliseconds with the milliseconds represented by the enumerator value.- Parameters:
time
- the time to increment- Returns:
- the given time minus the milliseconds represented by the value
- Since:
- 1.0
-
truncate
public long truncate(long time)Truncates the given time point by rounding it down to the nearest multitude of the milliseconds represented by the granularity value. Example: the granularityTHOUSAND
would adjust the time point 4366 to 4000.- Parameters:
time
- the time that needs adjustment- Returns:
- a number of milliseconds that is a multitude of the number of milliseconds represented by the enumerator value and that is still smaller than the given time
- Since:
- 1.0
-
getMillis
public long getMillis()Returns the number of milliseconds represented by the granularity.- Returns:
- number of milliseconds represented by the granularity
- Since:
- 1.0
-
addTo
- Specified by:
addTo
in interfaceTemporalUnit
-
between
- Specified by:
between
in interfaceTemporalUnit
-
getDuration
- Specified by:
getDuration
in interfaceTemporalUnit
-
isDateBased
public boolean isDateBased()- Specified by:
isDateBased
in interfaceTemporalUnit
-
isDurationEstimated
public boolean isDurationEstimated()- Specified by:
isDurationEstimated
in interfaceTemporalUnit
-
isSupportedBy
- Specified by:
isSupportedBy
in interfaceTemporalUnit
-
isTimeBased
public boolean isTimeBased()- Specified by:
isTimeBased
in interfaceTemporalUnit
-