Overview | Package | Class | Tree | Deprecated | Index | Help
| SSJ V. 2.1.1.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD

## umontreal.iro.lecuyer.util
Enum TimeUnit

    java.lang.Object
      java.lang.Enum<TimeUnit>
          umontreal.iro.lecuyer.util.TimeUnit

All Implemented Interfaces:
  Serializable, Comparable<TimeUnit>

    public enum TimeUnit

extends Enum<TimeUnit>

Enum Constant Summary
`DAY` Represents a day which has short name `d`.
`HOUR` Represents an hour which has short name `h`.
`MICROSECOND` Represents a microsecond which has short name `us`.
`MILLISECOND` Represents a millisecond which has short name `ms`.
`MINUTE` Represents a minute which has short name `min`.
`NANOSECOND` Represents a nanosecond which has short name `ns`.
`SECOND` Represents a second which has short name `s`.
`WEEK` Represents a week which has short name `w`.

Method Summary
`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.
`double` | `getHours()` Returns this time unit represented in hours.
`String` | `getLongName()` Returns the long name of this time unit.
`String` | `getShortName()` Returns the short name representing this unit in a string specifying a time duration.
`String` | `toString()` Calls `getLongName`.
`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.

Methods inherited from class java.lang.Enum
`compareTo, equals, getDeclaringClass, hashCode, name, ordinal, valueOf`

Methods inherited from class java.lang.Object
`getClass, notify, notifyAll, wait, wait, wait`

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(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:
    `IllegalArgumentException` - if this enum type has no constant with the specified name
    `NullPointerException` - if the argument is null

### getShortName

    public 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 String getLongName()

  Returns the long name of this time unit.

  Returns:
    the long name of this time unit.

### toString

    public String toString()

  Calls `getLongName`.

  Overrides:
    `toString` in class `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:
    `NullPointerException` - if `srcUnit` or `dstUnit` are `null`.

Overview | Package | Class | Tree | Deprecated | Index | Help
| SSJ V. 2.1.1.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.