Package com.norconex.commons.lang.time

# Enum Class DurationUnit

java.lang.Object
java.lang.Enum<DurationUnit>
com.norconex.commons.lang.time.DurationUnit

All Implemented Interfaces:
  `Serializable`, `Comparable<DurationUnit>`, `Constable`

public enum DurationUnit extends Enum<DurationUnit>
Duration unit. These units are best used with a general estimation is acceptable. The quantities for each units are fixed, and never change according to a specific era or moment in time. For instance a year is a fixed average of approximately 365.2425 days.

Since:
  2.0.0

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class java.lang.Enum

  `Enum.EnumDesc<E extends Enum<E>>`

- ## Enum Constant Summary

  Enum Constants
  Enum Constant
  Description
  `DAY`
  `HOUR`
  `MILLISECOND`
  `MINUTE`
  `MONTH`
  `SECOND`
  `WEEK`
  `YEAR`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static DurationUnit`
  `from(long duration)`
  Gets the largest unit fitting in the provided duration.
  `static DurationUnit`
  `from(String unit)`
  Gets the DurationUnit matching the provided string (case insensitive) or `null` if there are no units matching.
  `static DurationUnit`
  `from(Duration duration)`
  Gets the largest unit fitting in the provided duration.
  `static DurationUnit`
  `from(TemporalUnit temporalUnit)`
  `int`
  `reverseOrdinal()`
  Gets ordinal value in reverse order.
  `static DurationUnit[]`
  `reverseValues()`
  Returns all units from the highest (year), to the smallest (milliseconds).
  `long`
  `toDays()`
  `long`
  `toDays(long amount)`
  `Duration`
  `toDuration()`
  `long`
  `toHours()`
  `long`
  `toHours(long amount)`
  `long`
  `toMilliseconds()`
  `long`
  `toMilliseconds(long amount)`
  `long`
  `toMinutes()`
  `long`
  `toMinutes(long amount)`
  `long`
  `toMonths()`
  `long`
  `toMonths(long amount)`
  `long`
  `toSeconds()`
  `long`
  `toSeconds(long amount)`
  `ChronoUnit`
  `toTemporalUnit()`
  `long`
  `toUnit(DurationUnit targetUnit, long amount)`
  `long`
  `toWeeks()`
  `long`
  `toWeeks(long amount)`
  `long`
  `toYears()`
  `long`
  `toYears(long amount)`
  `static DurationUnit`
  `valueOf(String name)`
  Returns the enum constant of this class with the specified name.
  `static DurationUnit[]`
  `values()`
  Returns an array containing the constants of this enum class, in the order they are declared.

  ### Methods inherited from class java.lang.Enum

  `clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

  ### Methods inherited from class java.lang.Object

  `getClass, notify, notifyAll, wait, wait, wait`

- ## Enum Constant Details

  - ### MILLISECOND

    public static final DurationUnit MILLISECOND

  - ### SECOND

    public static final DurationUnit SECOND

  - ### MINUTE

    public static final DurationUnit MINUTE

  - ### HOUR

    public static final DurationUnit HOUR

  - ### DAY

    public static final DurationUnit DAY

  - ### WEEK

    public static final DurationUnit WEEK

  - ### MONTH

    public static final DurationUnit MONTH

  - ### YEAR

    public static final DurationUnit YEAR

- ## Method Details

  - ### values

    public static DurationUnit[] 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 DurationUnit 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

  - ### toTemporalUnit

    public ChronoUnit toTemporalUnit()

  - ### toDuration

    public Duration toDuration()

  - ### toMilliseconds

    public long toMilliseconds()

  - ### toMilliseconds

    public long toMilliseconds(long amount)

  - ### toSeconds

    public long toSeconds()

  - ### toSeconds

    public long toSeconds(long amount)

  - ### toMinutes

    public long toMinutes()

  - ### toMinutes

    public long toMinutes(long amount)

  - ### toHours

    public long toHours()

  - ### toHours

    public long toHours(long amount)

  - ### toDays

    public long toDays()

  - ### toDays

    public long toDays(long amount)

  - ### toWeeks

    public long toWeeks()

  - ### toWeeks

    public long toWeeks(long amount)

  - ### toMonths

    public long toMonths()

  - ### toMonths

    public long toMonths(long amount)

  - ### toYears

    public long toYears()

  - ### toYears

    public long toYears(long amount)

  - ### toUnit

    public long toUnit(DurationUnit targetUnit, long amount)

  - ### from

    public static DurationUnit from(Duration duration)
    Gets the largest unit fitting in the provided duration. If the duration is `null`, zero, or less, `null` is returned.
    Parameters:
      `duration` - duration in milliseconds
    Returns:
      duration unit

  - ### from

    public static DurationUnit from(long duration)
    Gets the largest unit fitting in the provided duration. If the duration is zero or less, `null` is returned.
    Parameters:
      `duration` - duration in milliseconds
    Returns:
      duration unit

  - ### from

    public static DurationUnit from(String unit)
    Gets the DurationUnit matching the provided string (case insensitive) or `null` if there are no units matching.
    Parameters:
      `unit` - unit name
    Returns:
      duration unit

  - ### from

    public static DurationUnit from(TemporalUnit temporalUnit)

  - ### reverseValues

    public static DurationUnit[] reverseValues()
    Returns all units from the highest (year), to the smallest (milliseconds).
    Returns:
      duration units

  - ### reverseOrdinal

    public int reverseOrdinal()
    Gets ordinal value in reverse order.
    Returns:
      ordinal value