Enum ChronoUnit
- All Implemented Interfaces:
Comparable<ChronoUnit>, TemporalUnit
The units of the ISO calendar, with the JDK's order, names and lengths.
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionA hundred years.A day.Ten years.An era, estimated as a billion years.Forever: longer than any other unit.Twelve hours.An hour.A microsecond.A thousand years.A millisecond.A minute.A month, estimated as a twelfth of a year.A nanosecond.A second.Seven days.A year, estimated as 365.2425 days. -
Method Summary
Modifier and TypeMethodDescription<R extends Temporal>
RaddTo(R temporal, long amount) temporalmoved byamountof this unit.longHow many whole units lie between two values of the same kind.The length of one unit; an estimate for the units a calendar decides.booleanWhether this is a unit of a date: a day or longer.booleanWhether the length is an estimate.booleanisSupportedBy(Temporal temporal) Whethertemporalcan add or subtract this unit.booleanWhether this is a unit of a time of day: shorter than a day.toString()Returns a string representation of the object.static ChronoUnitReturns the enum constant of this type with the specified name.static ChronoUnit[]values()Returns an array containing the constants of this enum type, in the order they are declared.Methods inherited from class Enum
clone, compareTo, equals, getDeclaringClass, getEnumValues, hashCode, name, ordinal, setEnumValues, valueOf
-
Enum Constant Details
-
NANOS
A nanosecond. -
MICROS
A microsecond. -
MILLIS
A millisecond. -
SECONDS
A second. -
MINUTES
A minute. -
HOURS
An hour. -
HALF_DAYS
Twelve hours. -
DAYS
A day. -
WEEKS
Seven days. -
MONTHS
A month, estimated as a twelfth of a year. -
YEARS
A year, estimated as 365.2425 days. -
DECADES
Ten years. -
CENTURIES
A hundred years. -
MILLENNIA
A thousand years. -
ERAS
An era, estimated as a billion years. -
FOREVER
Forever: longer than any other unit.
-
-
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
-
getDuration
Description copied from interface:TemporalUnitThe length of one unit; an estimate for the units a calendar decides.- Specified by:
getDurationin interfaceTemporalUnit
-
isDurationEstimated
public boolean isDurationEstimated()Description copied from interface:TemporalUnitWhether the length is an estimate.- Specified by:
isDurationEstimatedin interfaceTemporalUnit
-
isDateBased
public boolean isDateBased()Description copied from interface:TemporalUnitWhether this is a unit of a date: a day or longer.- Specified by:
isDateBasedin interfaceTemporalUnit
-
isTimeBased
public boolean isTimeBased()Description copied from interface:TemporalUnitWhether this is a unit of a time of day: shorter than a day.- Specified by:
isTimeBasedin interfaceTemporalUnit
-
isSupportedBy
Description copied from interface:TemporalUnitWhether
temporalcan add or subtract this unit.Answered by the unit's kind for the built-in temporals and otherwise by trying to add one, as the JDK's default does. It never asks
temporal.isSupported(this): that is what calls here, so a custom unit relying on this default would recurse.- Specified by:
isSupportedByin interfaceTemporalUnit
-
addTo
Description copied from interface:TemporalUnittemporalmoved byamountof this unit.- Specified by:
addToin interfaceTemporalUnit
-
between
Description copied from interface:TemporalUnitHow many whole units lie between two values of the same kind.- Specified by:
betweenin interfaceTemporalUnit
-
toString
Description copied from class:ObjectReturns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())- Overrides:
toStringin classEnum<ChronoUnit>
-