umontreal.iro.lecuyer.util
Enum TimeUnit
- java.lang.Object
-
- java.lang.Enum<TimeUnit>
-
- umontreal.iro.lecuyer.util.TimeUnit
-
-
Enum Constant Summary
Enum Constants Enum Constant and Description DAYRepresents a day which has short name d.HOURRepresents an hour which has short name h.MICROSECONDRepresents a microsecond which has short name us.MILLISECONDRepresents a millisecond which has short name ms.MINUTERepresents a minute which has short name min.NANOSECONDRepresents a nanosecond which has short name ns.SECONDRepresents a second which has short name s.WEEKRepresents a week which has short name w.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static doubleconvert(double value, TimeUnit srcUnit, TimeUnit dstUnit)Converts value expressed in time unit srcUnit to a time duration expressed in dstUnit and returns the result of the conversion.doublegetHours()Returns this time unit represented in hours.java.lang.StringgetLongName()Returns the long name of this time unit.java.lang.StringgetShortName()Returns the short name representing this unit in a string specifying a time duration.java.lang.StringtoString()CallsgetLongName.static TimeUnitvalueOf(java.lang.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.
-
-
-
Enum Constant Detail
-
NANOSECOND
public static final TimeUnit NANOSECOND
Represents a nanosecond which has short name ns.
-
MICROSECOND
public static final TimeUnit MICROSECOND
Represents a microsecond which has short name us.
-
MILLISECOND
public static final TimeUnit MILLISECOND
Represents a millisecond which has short name ms.
-
SECOND
public static final TimeUnit SECOND
Represents a second which has short name s.
-
MINUTE
public static final TimeUnit MINUTE
Represents a minute which has short name min.
-
HOUR
public static final TimeUnit HOUR
Represents an hour which has short name h.
-
DAY
public static final TimeUnit DAY
Represents a day which has short name d.
-
WEEK
public static final TimeUnit WEEK
Represents a week which has short name w.
-
-
Method Detail
-
values
public static TimeUnit[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (TimeUnit c : TimeUnit.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static TimeUnit valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
getShortName
public java.lang.String getShortName()
Returns the short name representing this unit in a string specifying a time duration.- Returns:
- the short name of this time unit.
-
getLongName
public java.lang.String getLongName()
Returns the long name of this time unit.- Returns:
- the long name of this time unit.
-
toString
public java.lang.String toString()
CallsgetLongName.- Overrides:
toStringin classjava.lang.Enum<TimeUnit>- Returns:
- the result of
getLongName.
-
getHours
public double getHours()
Returns this time unit represented in hours. This returns the number of hours corresponding to one unit.- Returns:
- the time unit represented in hours.
-
convert
public static double convert(double value, TimeUnit srcUnit, TimeUnit dstUnit)Converts value expressed in time unit srcUnit to a time duration expressed in dstUnit and returns the result of the conversion.- Parameters:
value- the value being converted.srcUnit- the source time unit.dstUnit- the destination time unit.- Returns:
- the converted value.
- Throws:
java.lang.NullPointerException- if srcUnit or dstUnit are null.
-
-
DMelt 3.0 © DataMelt by jWork.ORG