|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |
java.lang.Objectjava.lang.Enum<DurationUnit>
org.opends.server.admin.DurationUnit
public enum DurationUnit
This enumeration defines various duration units.
Enum Constant Summary | |
---|---|
DAYS
A day unit. |
|
HOURS
An hour unit. |
|
MILLI_SECONDS
A millisecond unit. |
|
MINUTES
A minute unit. |
|
SECONDS
A second unit. |
|
WEEKS
A week unit. |
Method Summary | |
---|---|
double |
fromMilliSeconds(long duration)
Converts the specified duration in milliseconds to this unit. |
long |
getDuration()
Get the number of milliseconds that this unit represents. |
java.lang.String |
getLongName()
Get the long name of this unit. |
java.lang.String |
getShortName()
Get the abbreviated name of this unit. |
static DurationUnit |
getUnit(java.lang.String s)
Get the unit corresponding to the provided unit name. |
static long |
parseValue(java.lang.String s)
Parse the provided duration string and return its equivalent duration in milliseconds. |
static long |
parseValue(java.lang.String s,
DurationUnit defaultUnit)
Parse the provided duration string and return its equivalent duration in milliseconds. |
long |
toMilliSeconds(double duration)
Converts the specified duration in this unit to milliseconds. |
java.lang.String |
toString()
|
static java.lang.String |
toString(long duration)
Returns a string representation of the provided duration. |
static DurationUnit |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. |
static DurationUnit[] |
values()
Returns an array containing the constants of this enum type, in the order they are declared. |
Methods inherited from class java.lang.Enum |
---|
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Enum Constant Detail |
---|
public static final DurationUnit DAYS
public static final DurationUnit HOURS
public static final DurationUnit MILLI_SECONDS
public static final DurationUnit MINUTES
public static final DurationUnit SECONDS
public static final DurationUnit WEEKS
Method Detail |
---|
public static DurationUnit[] values()
for (DurationUnit c : DurationUnit.values()) System.out.println(c);
public static DurationUnit valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.
java.lang.IllegalArgumentException
- if this enum type has no constant
with the specified name
java.lang.NullPointerException
- if the argument is nullpublic static DurationUnit getUnit(java.lang.String s) throws java.lang.IllegalArgumentException
s
- The name of the unit. Can be the abbreviated or long
name and can contain white space and mixed case
characters.
java.lang.IllegalArgumentException
- If the provided name did not correspond to a known
duration unit.public static long parseValue(java.lang.String s) throws java.lang.NumberFormatException
toString(long)
method.
Therefore, a duration can comprise of multiple duration
specifiers, for example 1d15m25s
.
s
- The duration string to be parsed.
java.lang.NumberFormatException
- If the provided duration string could not be parsed.toString(long)
public static long parseValue(java.lang.String s, DurationUnit defaultUnit) throws java.lang.NumberFormatException
toString(long)
method.
Therefore, a duration can comprise of multiple duration
specifiers, for example 1d15m25s
.
s
- The duration string to be parsed.defaultUnit
- The default unit to use if there is no unit specified in
the duration string, or null
if the
string must always contain a unit.
java.lang.NumberFormatException
- If the provided duration string could not be parsed.toString(long)
public static java.lang.String toString(long duration) throws java.lang.IllegalArgumentException
parseValue(String)
method. The string representation is
comprised of one or more of the number of weeks, days, hours,
minutes, seconds, and milliseconds. Here are some examples:
toString(0) // 0 ms toString(999) // 999 ms toString(1000) // 1 s toString(1500) // 1 s 500 ms toString(3650000) // 1 h 50 s toString(3700000) // 1 h 1 m 40 s
duration
- The duration in milliseconds.
java.lang.IllegalArgumentException
- If the provided duration is negative.parseValue(String)
,
parseValue(String, DurationUnit)
public double fromMilliSeconds(long duration)
duration
- The duration in milliseconds.
public long getDuration()
public java.lang.String getLongName()
public java.lang.String getShortName()
public long toMilliSeconds(double duration)
duration
- The duration as a quantity of this unit.
public java.lang.String toString()
This implementation returns the abbreviated name of this duration unit.
toString
in class java.lang.Enum<DurationUnit>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |