public enum TimeUnit extends Enum<TimeUnit>
TimeUnit
is an enum that defines a period of time. There is a
method to convert a time to milliseconds using the time unit.Enum Constant and Description |
---|
DAY |
HOUR |
MICROSECOND |
MILLISECOND |
MINUTE |
SECOND |
Modifier and Type | Method and Description |
---|---|
Long |
asMilliSeconds(Long time)
Converts a unit of time to milliseconds.
|
static Long |
asMilliSeconds(TimeUnit timeUnit,
Long time)
Converts a unit of time to milliseconds.
|
Long |
fromMilliSeconds(Long time) |
static Long |
fromMilliSeconds(TimeUnit timeUnit,
Long time) |
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 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 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 static Long asMilliSeconds(TimeUnit timeUnit, Long time)
timeUnit
- the time unittime
- the timepublic Long asMilliSeconds(Long time)
time
- the timeCopyright © 2021. All rights reserved.