public enum TimeUnit extends Enum<TimeUnit>
Enum Constant and Description |
---|
HOURS |
MICROSECONDS |
MILLISECONDS |
MINUTES |
NANOSECONDS |
SECONDS |
Modifier and Type | Method and Description |
---|---|
long |
convert(long sourceDuration,
TimeUnit sourceUnit)
Convert the given time duration in the given unit to this unit.
|
String |
getAbbreviation()
Return the abbreviation of this TimeUnit, "h" for hours, "min" for
minutes, "s" for seconds, "ms" for milliseconds, "μs" for microseconds
and "ns" for nanoseconds.
|
long |
round(long sourceDuration,
TimeUnit timeUnit)
Round the given time duration in the given unit to this unit.
|
long |
roundToHours(long duration)
Equivalent to HOURS.round(duration, this).
|
long |
roundToMicros(long duration)
Equivalent to MICROSECONDS.round(duration, this).
|
long |
roundToMillis(long duration)
Equivalent to MILLISECONDS.round(duration, this).
|
long |
roundToMinutes(long duration)
Equivalent to MINUTES.round(duration, this).
|
long |
roundToNanos(long duration)
Equivalent to NANOSECONDS.round(duration, this).
|
long |
roundToSeconds(long duration)
Equivalent to SECONDS.round(duration, this).
|
long |
toHours(long duration)
Equivalent to HOURS.convert(duration, this).
|
long |
toMicros(long duration)
Equivalent to MICROSECONDS.convert(duration, this).
|
long |
toMillis(long duration)
Equivalent to MILLISECONDS.convert(duration, this).
|
long |
toMinutes(long duration)
Equivalent to MINUTES.convert(duration, this).
|
long |
toNanos(long duration)
Equivalent to NANOSECONDS.convert(duration, this).
|
long |
toSeconds(long duration)
Equivalent to SECONDS.convert(duration, this).
|
String |
toString() |
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 HOURS
public static final TimeUnit MINUTES
public static final TimeUnit SECONDS
public static final TimeUnit MILLISECONDS
public static final TimeUnit MICROSECONDS
public static final TimeUnit NANOSECONDS
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 String getAbbreviation()
public long convert(long sourceDuration, TimeUnit sourceUnit)
sourceDuration
- the time duration in the given sourceUnitsourceUnit
- the unit of the sourceDuration argumentpublic long round(long sourceDuration, TimeUnit timeUnit)
sourceDuration
- the time duration in the given sourceUnittimeUnit
- the unit of the sourceDuration argumentpublic long toHours(long duration)
duration
- the durationpublic long toMicros(long duration)
duration
- the durationpublic long toMillis(long duration)
duration
- the durationpublic long toMinutes(long duration)
duration
- the durationpublic long toNanos(long duration)
duration
- the durationpublic long toSeconds(long duration)
duration
- the durationpublic long roundToHours(long duration)
duration
- the durationpublic long roundToMicros(long duration)
duration
- the durationpublic long roundToMillis(long duration)
duration
- the durationpublic long roundToMinutes(long duration)
duration
- the durationpublic long roundToNanos(long duration)
duration
- the durationpublic long roundToSeconds(long duration)
duration
- the durationCopyright © 2014–2018 GraphIK (INRIA - LIRMM). All rights reserved.