- 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 BILLIONA granularity representing one billion milliseconds.BILLION_HUNDREDA granularity representing one hundred billion milliseconds.BILLION_TENA granularity representing ten billion milliseconds.HUNDREDA granularity representing one hundred milliseconds.MILLIONA granularity representing one million milliseconds.MILLION_HUNDREDA granularity representing one hundred million milliseconds.MILLION_TENA granularity representing ten million milliseconds.ONEA granularity representing one millisecond.TENA granularity representing ten milliseconds.THOUSANDA granularity representing one thousand milliseconds.THOUSAND_HUNDREDA granularity representing one hundred thousand milliseconds.THOUSAND_TENA granularity representing ten thousand milliseconds.TRILLIONA granularity representing one trillion milliseconds. -
Method Summary
Modifier and Type Method Description <R extends Temporal>
RaddTo(R temporal, long periodToAdd)longbetween(Temporal t1, Temporal t2)longdecrement(long time)Decrements the given number of milliseconds with the milliseconds represented by the enumerator value.DurationgetDuration()longgetMillis()Returns the number of milliseconds represented by the granularity.longincrement(long time)Increments the given number of milliseconds with the milliseconds represented by the enumerator value.booleanisDateBased()booleanisDurationEstimated()booleanisSupportedBy(Temporal temporal)booleanisTimeBased()longtruncate(long time)Truncates the given time point by rounding it down to the nearest multitude of the milliseconds represented by the granularity value.static SimpleUnitvalueOf(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, valueOfMethods 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 granularityTHOUSANDwould 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:
addToin interfaceTemporalUnit
-
between
- Specified by:
betweenin interfaceTemporalUnit
-
getDuration
- Specified by:
getDurationin interfaceTemporalUnit
-
isDateBased
public boolean isDateBased()- Specified by:
isDateBasedin interfaceTemporalUnit
-
isDurationEstimated
public boolean isDurationEstimated()- Specified by:
isDurationEstimatedin interfaceTemporalUnit
-
isSupportedBy
- Specified by:
isSupportedByin interfaceTemporalUnit
-
isTimeBased
public boolean isTimeBased()- Specified by:
isTimeBasedin interfaceTemporalUnit
-