Class 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 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
    • 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