Enum Class TimeUnit

java.lang.Object
java.lang.Enum<TimeUnit>
com.irurueta.units.TimeUnit
All Implemented Interfaces:
Serializable, Comparable<TimeUnit>, Constable

public enum TimeUnit extends Enum<TimeUnit>
Enumerator containing recognized typical time units.
  • Enum Constant Details

    • NANOSECOND

      public static final TimeUnit NANOSECOND
      Nanosecond time unit. This belongs to the International System of units.
    • MICROSECOND

      public static final TimeUnit MICROSECOND
      Microsecond time unit. This belongs to the International System of units.
    • MILLISECOND

      public static final TimeUnit MILLISECOND
      Millisecond time unit. This belongs to the International System of units.
    • SECOND

      public static final TimeUnit SECOND
      Second time unit. This belongs to the International System of units.
    • MINUTE

      public static final TimeUnit MINUTE
      Minute time unit.
    • HOUR

      public static final TimeUnit HOUR
      Hour time unit.
    • DAY

      public static final TimeUnit DAY
      Day time unit.
    • WEEK

      public static final TimeUnit WEEK
      Week time unit.
    • MONTH

      public static final TimeUnit MONTH
      Month time unit (considered as 30 days).
    • YEAR

      public static final TimeUnit YEAR
      Year time unit (considered as 365 days).
    • CENTURY

      public static final TimeUnit CENTURY
      Century time unit (considered as 100 years).
  • Constructor Details

    • TimeUnit

      private TimeUnit()
  • 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
    • getUnitSystem

      public static UnitSystem getUnitSystem(TimeUnit unit)
      Returns unit system for provided time unit.
      Parameters:
      unit - time unit to be checked.
      Returns:
      returns metric system only for units belonging to the International System of units.
      Throws:
      IllegalArgumentException - if unit is null or does not belong to the international system of units.
    • getMetricUnits

      public static TimeUnit[] getMetricUnits()
      Gets all supported metric time units.
      Returns:
      all supported metric time units.
    • getNonInternationalSystemUnits

      public static TimeUnit[] getNonInternationalSystemUnits()
      Gets all supported units not belonging to the International System of Units.
      Returns:
      all units not belonging to the International System of Units.
    • isMetric

      public static boolean isMetric(TimeUnit unit)
      Indicates whether provided unit belongs to the metric unit system.
      Parameters:
      unit - time unit to be checked.
      Returns:
      true if unit belongs to metric unit system.
      Throws:
      IllegalArgumentException - if unit is null or not supported.
    • isNonInternationalSystem

      public static boolean isNonInternationalSystem(TimeUnit unit)
      Indicates whether provided unit belongs to the International System of units.
      Parameters:
      unit - time unit to be checked.
      Returns:
      true if unit does not belong to the International System of units, false otherwise.
      Throws:
      IllegalArgumentException - if unit is null or not supported.