public enum TimeUnit extends Enum<TimeUnit>
ChronoUnit together with a length of time to create a broader set of time units than
those provided by ChronoUnit and to allow additional functionality. For even more fine-tuned time modeling
use the TimePeriod class.| Enum Constant and Description |
|---|
CENTURY |
DAY |
DECADE |
HOUR |
MICROSECOND |
MILLISECOND |
MINUTE |
MONTH |
NANOSECOND |
QUARTER |
SECOND |
WEEK |
YEAR |
| Modifier and Type | Method and Description |
|---|---|
double |
frequencyPer(TimePeriod timePeriod)
Compute and return the number of times this time unit occurs in the given time period.
|
double |
frequencyPer(TimeUnit otherTimeUnit)
Compute and return the number of times this time unit occurs in another time unit.
|
TemporalUnit |
temporalUnit()
The temporal unit used as the basis for this time unit.
|
String |
toString() |
long |
unitLength()
The length of this time unit relative to the underlying temporal unit.
|
static TimeUnit |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static TimeUnit[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final TimeUnit CENTURY
public static final TimeUnit DECADE
public static final TimeUnit YEAR
public static final TimeUnit QUARTER
public static final TimeUnit MONTH
public static final TimeUnit WEEK
public static final TimeUnit DAY
public static final TimeUnit HOUR
public static final TimeUnit MINUTE
public static final TimeUnit SECOND
public static final TimeUnit MILLISECOND
public static final TimeUnit MICROSECOND
public static final TimeUnit NANOSECOND
public static TimeUnit[] values()
for (TimeUnit c : TimeUnit.values()) System.out.println(c);
public static TimeUnit 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 TemporalUnit temporalUnit()
public long unitLength()
public double frequencyPer(TimeUnit otherTimeUnit)
For example, if this time unit is a month and the other time unit is a year, the return value is 12, since a month occurs 12 times in one year.
otherTimeUnit - the time unit for which the frequency of occurrence of this time unit is to be found.public double frequencyPer(TimePeriod timePeriod)
For example, if this time unit is a month and the given time period is half a year, the return value is 6, since a month occurs 6 times in one year.
timePeriod - the time period for which the frequency of occurrence of this time unit is to be found.