Package org.firebirdsql.gds.ng

## Class DatatypeCoder.RawDateTimeStruct

- java.lang.Object
- - org.firebirdsql.gds.ng.DatatypeCoder.RawDateTimeStruct

- Enclosing interface:
    DatatypeCoder

      public static final class DatatypeCoder.RawDateTimeStruct
      extends java.lang.Object

  Raw date/time value.

  Fractions are sub-second precision in 100 microseconds.

  We cannot simply pass millis to the database, because Firebird stores timestamp in format (citing Ann W. Harrison):

  "[timestamp is] stored a two long words, one representing the number of days since 17 Nov 1858 and one representing number of 100 nano-seconds since midnight" (NOTE: It is actually 100 microseconds!)

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `int` | `day` |
    `int` | `fractions` |
    `int` | `hour` |
    `int` | `minute` |
    `int` | `month` |
    `int` | `second` |
    `int` | `year` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `RawDateTimeStruct()` |
    `RawDateTimeStruct​(int encodedDate, boolean hasDate, int encodedTime, boolean hasTime)` | Initializes a raw date/time value from encoded time and/or date integers.
    `RawDateTimeStruct​(DatatypeCoder.RawDateTimeStruct raw)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `int` | `getEncodedDate()` | Encodes the date as used by Firebird (Modified Julian Date, or number of days since 17 November 1858).
    `int` | `getEncodedTime()` | Encodes the time as used by Firebird (fractions (100 milliseconds) in a day).
    `int` | `getFractionsAsNanos()` |
    `void` | `setFractionsFromNanos​(long nanos)` | Sets the sub-second fraction (100 microseconds) from a nanosecond value.

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### year

          public int year

    - #### month

          public int month

    - #### day

          public int day

    - #### hour

          public int hour

    - #### minute

          public int minute

    - #### second

          public int second

    - #### fractions

          public int fractions

  - ### Constructor Detail

    - #### RawDateTimeStruct

          public RawDateTimeStruct()

    - #### RawDateTimeStruct

          public RawDateTimeStruct​(int encodedDate,
                                   boolean hasDate,
                                   int encodedTime,
                                   boolean hasTime)

      Initializes a raw date/time value from encoded time and/or date integers.
      Parameters:
        `encodedDate` - Encoded date (Modified Julian Date)
        `hasDate` - If date should be decoded (set `false` for a time-only value)
        `encodedTime` - Encoded time (fractions in day)
        `hasTime` - If time should be decoded (set `false` for a date-only value)
      Since:
        4.0

    - #### RawDateTimeStruct

          public RawDateTimeStruct​(DatatypeCoder.RawDateTimeStruct raw)

  - ### Method Detail

    - #### getFractionsAsNanos

          public int getFractionsAsNanos()

    - #### setFractionsFromNanos

          public void setFractionsFromNanos​(long nanos)

      Sets the sub-second fraction (100 microseconds) from a nanosecond value.
      Parameters:
        `nanos` - Sub-second nanoseconds
      Since:
        4.0

    - #### getEncodedDate

          public int getEncodedDate()

      Encodes the date as used by Firebird (Modified Julian Date, or number of days since 17 November 1858).
      Returns:
        Encoded date
      Since:
        4.0

    - #### getEncodedTime

          public int getEncodedTime()

      Encodes the time as used by Firebird (fractions (100 milliseconds) in a day).
      Returns:
        Encoded time
      Since:
        4.0