public enum TimeUnit extends Enum<TimeUnit>
| Enum Constant and Description |
|---|
HOURS
Time unit representing sixty minutes
|
MINUTES
Time unit representing sixty second
|
SECONDS
Time unit representing one second
|
| Modifier and Type | Field and Description |
|---|---|
static TimeUnit |
DEFAULT
The default time unit
|
| Modifier and Type | Method and Description |
|---|---|
long |
convert(long amount,
TimeUnit sourceTimeUnit)
Converts the given time duration from a source Time Unit to this Time Unit.
|
static TimeUnit |
findByIdentifier(String identifier)
Returns a
TimeUnit that is identifiable by the given string. |
int |
getCalendarConstant()
Returns the
Calendar constant associated with this Time Unit. |
boolean |
isIdentifiableBy(String identifier)
Checks a given string against a list of known identifiers for a
TimeUnit,
returning true if a match is found. |
long |
toMillis(long amount)
Converts the given amount into milliseconds.
|
String |
toString()
Returns a string representation of this
TimeUnit. |
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 SECONDS
public static final TimeUnit MINUTES
public static final TimeUnit HOURS
public static final TimeUnit DEFAULT
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 TimeUnit findByIdentifier(String identifier)
TimeUnit that is identifiable by the given string.
For example, all of the following strings match to SECONDS:
identifier - a string that identified a Time UnitTimeUnit, not nullIllegalArgumentException - if no time unit matches the given identifierpublic boolean isIdentifiableBy(String identifier)
TimeUnit,
returning true if a match is found.identifier - the identifier to be checkedtrue if this TimeUnit is identifiable by the given identifier;
false, otherwise.public int getCalendarConstant()
Calendar constant associated with this Time Unit.Calendar constantpublic String toString()
TimeUnit.public long toMillis(long amount)
amount - the amount to be convertedpublic long convert(long amount,
TimeUnit sourceTimeUnit)
amount - the time duration amount to be convertedsourceTimeUnit - the time unit of the duration parameterCopyright © 2021. All rights reserved.