org.apache.cassandra.cql3

## Class Duration

- java.lang.Object
- - org.apache.cassandra.cql3.Duration

-     public final class Duration
      extends java.lang.Object

  Represents a duration. A durations store separately months, days, and seconds due to the fact that the number of days in a month varies, and a day can have 23 or 25 hours if a daylight saving is involved.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DAYS_PER_WEEK`
    `static int` | `MONTHS_PER_YEAR`
    `static long` | `NANOS_PER_HOUR`
    `static long` | `NANOS_PER_MICRO`
    `static long` | `NANOS_PER_MILLI`
    `static long` | `NANOS_PER_MINUTE`
    `static long` | `NANOS_PER_SECOND`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(java.lang.Object obj)`
    `static Duration` | `from(java.lang.String input)` Converts a `String` into a duration.
    `int` | `getDays()`
    `int` | `getMonths()`
    `long` | `getNanoseconds()`
    `int` | `hashCode()`
    `static Duration` | `newInstance(int months, int days, long nanoseconds)`
    `java.lang.String` | `toString()`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### NANOS_PER_MICRO

          public static final long NANOS_PER_MICRO

      See Also:
        Constant Field Values

    - #### NANOS_PER_MILLI

          public static final long NANOS_PER_MILLI

      See Also:
        Constant Field Values

    - #### NANOS_PER_SECOND

          public static final long NANOS_PER_SECOND

      See Also:
        Constant Field Values

    - #### NANOS_PER_MINUTE

          public static final long NANOS_PER_MINUTE

      See Also:
        Constant Field Values

    - #### NANOS_PER_HOUR

          public static final long NANOS_PER_HOUR

      See Also:
        Constant Field Values

    - #### DAYS_PER_WEEK

          public static final int DAYS_PER_WEEK

      See Also:
        Constant Field Values

    - #### MONTHS_PER_YEAR

          public static final int MONTHS_PER_YEAR

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### newInstance

          public static Duration newInstance(int months,
                                             int days,
                                             long nanoseconds)

    - #### from

          public static Duration from(java.lang.String input)

      Converts a `String` into a duration.

      The accepted formats are:

      - multiple digits followed by a time unit like: 12h30m where the time unit can be:
        - `y`: years
        - `m`: months
        - `w`: weeks
        - `d`: days
        - `h`: hours
        - `m`: minutes
        - `s`: seconds
        - `ms`: milliseconds
        - `us` or `µs`: microseconds
        - `ns`: nanoseconds
      - ISO 8601 format: P[n]Y[n]M[n]DT[n]H[n]M[n]S or P[n]W
      - ISO 8601 alternative format: P[YYYY]-[MM]-[DD]T[hh]:[mm]:[ss]
      Parameters:
        `input` - the `String` to convert
      Returns:
        a number of nanoseconds

    - #### getMonths

          public int getMonths()

    - #### getDays

          public int getDays()

    - #### getNanoseconds

          public long getNanoseconds()

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### equals

          public boolean equals(java.lang.Object obj)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

Copyright © 2018 The Apache Software Foundation