Enum Class TimeUnit

java.lang.Object
java.lang.Enum<TimeUnit>
org.refcodes.time.TimeUnit
All Implemented Interfaces:
Serializable, Comparable<TimeUnit>, Constable

public enum TimeUnit extends Enum<TimeUnit>
The Enum TimeUnit.
Author:
steiner
  • Enum Constant Details

    • NANOSECOND

      public static final TimeUnit NANOSECOND
    • MILLISECOND

      public static final TimeUnit MILLISECOND
    • SECOND

      public static final TimeUnit SECOND
    • MINUTE

      public static final TimeUnit MINUTE
    • HOUR

      public static final TimeUnit HOUR
    • DAY

      public static final TimeUnit DAY
    • YEAR

      public static final TimeUnit YEAR
  • Method Details

    • values

      public static TimeUnit[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static TimeUnit valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified name
      NullPointerException - if the argument is null
    • getMilliseconds

      public long getMilliseconds()
      Returns the divisor for the time unit to be converted to seconds.
      Returns:
      Divisor for the time unit to be converted to seconds.
    • toTime

      public float toTime(TimeUnit aFromTimeUnit, long aFromTime)
      Converts a given time from one TimeUnit to this instance's time unit.
      Parameters:
      aFromTimeUnit - The TimeUnit to convert from.
      aFromTime - The time to be converted.
      Returns:
      The converted time as of the current instance's time unit.
    • toTimeUnit

      public static float toTimeUnit(TimeUnit aFromTimeUnit, long aTime, TimeUnit aToTimeUnit)
      Converts a given time from one TimeUnit to another TimeUnit.
      Parameters:
      aFromTimeUnit - The TimeUnit to convert from.
      aTime - The time to be converted.
      aToTimeUnit - The TimeUnit to convert to.
      Returns:
      The converted time.
    • toMilliseconds

      public static long toMilliseconds(TimeUnit aTimeUnit, long aTime)
      Converts a given time from the provided TimeUnit to milliseconds.
      Parameters:
      aTimeUnit - The TimeUnit to convert from.
      aTime - The time to be converted to milliseconds.
      Returns:
      The converted time in milliseconds.