com.tibco.datagrid

## Class TibDateTime

- java.lang.Object
- - com.tibco.datagrid.TibDateTime

- All Implemented Interfaces:
    java.lang.Comparable<java.lang.Object>

      public class TibDateTime
      extends java.lang.Object
      implements java.lang.Comparable<java.lang.Object>

  This class represents date and time values with large range and nanosecond precision.

  `tibDateTime` values combine two numeric components.

  - The `sec` component represents whole seconds with up to 64 bits. Zero denotes the UNIX epoch -- midnight entering January 1, 1970.
  - The `nsec` component represents nanoseconds after the time that the `sec` component denotes. Although the struct stores this component in a signed 64-bit integer, this component is always non-negative, between zero and 999999999.
  For example, the value -1 seconds plus 999,999,998 nanoseconds represents December 31, 1969, 2 nanoseconds before midnight (that is, 2 nanoseconds before the epoch).

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TibDateTime()` Create a TibDateTime object denoting January 1, 1970, 00:00:00.000000000 GMT (that is, the epoch).

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(java.lang.Object obj)` Compare this TibDateTime object to the method's argument.
    `boolean` | `equals(java.lang.Object obj)` Test equivalence of this TibDateTime object to the method's argument.
    `long` | `getNanoseconds()` Get the nanoseconds component of a TibDateTime object.
    `long` | `getSeconds()` Get the seconds component of a TibDateTime object.
    `int` | `hashCode()` Return a hash code value for this TibDateTime.
    `void` | `set(long sec, long nsec)` Modify a TibDateTime object by setting its seconds and nanoseconds components.
    `void` | `setFromDate(java.util.Date date)` Modify a TibDateTime object so it represents a time equivalent to a `java.util.Date` object.
    `void` | `setFromMillis(long millis)` Modify a TibDateTime object by converting from milliseconds relative to January 1, 1970, 00:00:00 GMT (that is, the epoch), and setting its components to the equivalent time.
    `java.util.Date` | `toDate()` Convert a TibDateTime object to a `java.util.Date` object.
    `long` | `toMillis()` Convert a TibDateTime object to milliseconds.
    `java.lang.String` | `toString()` Return a printable string representing this TibDateTime.

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

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

- - ### Constructor Detail

    - #### TibDateTime

          public TibDateTime()

      Create a TibDateTime object denoting January 1, 1970, 00:00:00.000000000 GMT (that is, the epoch).

  - ### Method Detail

    - #### set

          public void set(long sec,
                          long nsec)
                   throws DataGridInvalidArgumentException

      Modify a TibDateTime object by setting its seconds and nanoseconds components.
      Parameters:
        `sec` - Positive values represent seconds since the epoch. Negative values represent seconds before the epoch.
        `nsec` - Nanoseconds after the time that the `sec` field denotes; must be in the range [0, 999999999].
      Throws:
        `DataGridInvalidArgumentException` - if the value supplied for nanoseconds is not in the range [0, 999999999].

    - #### setFromMillis

          public void setFromMillis(long millis)

      Modify a TibDateTime object by converting from milliseconds relative to January 1, 1970, 00:00:00 GMT (that is, the epoch), and setting its components to the equivalent time.
      Parameters:
        `millis` - Positive values represent milliseconds since the epoch. Negative values represent milliseconds before the epoch.

    - #### setFromDate

          public void setFromDate(java.util.Date date)

      Modify a TibDateTime object so it represents a time equivalent to a `java.util.Date` object.
      Parameters:
        `date` - A `java.util.Date` object

    - #### getSeconds

          public long getSeconds()

      Get the seconds component of a TibDateTime object.

      Seconds are relative to the epoch -- namely January 1, 1970, 00:00:00 GMT.

      Returns:
        the seconds component

    - #### getNanoseconds

          public long getNanoseconds()

      Get the nanoseconds component of a TibDateTime object.

      Nanoseconds are after the time that the `seconds` component denotes.

      Returns:
        the nanoseconds component

    - #### toMillis

          public long toMillis()
                        throws DataGridOutOfRangeException

      Convert a TibDateTime object to milliseconds.

      Milliseconds are relative to the epoch -- namely January 1, 1970, 00:00:00 GMT.

      Returns:
        the TibDateTime value in milliseconds
      Throws:
        `DataGridOutOfRangeException` - if the TibDateTime value is beyond the range that can be represented as milliseconds.

    - #### toDate

          public java.util.Date toDate()
                                throws DataGridOutOfRangeException

      Convert a TibDateTime object to a `java.util.Date` object.

      The precision of `java.util.Date` objects is milliseconds. When converting, this method rounds to the nearest millisecond.

      Returns:
        a `java.util.Date` object
      Throws:
        `DataGridOutOfRangeException` - if the TibDateTime value is beyond the range that a `java.util.Date` object can represent.

    - #### hashCode

          public int hashCode()

      Return a hash code value for this TibDateTime.
      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### equals

          public boolean equals(java.lang.Object obj)

      Test equivalence of this TibDateTime object to the method's argument.
      Overrides:
        `equals` in class `java.lang.Object`
      Parameters:
        `obj` - The second object in the equivalence.
      Returns:
        - `true` when this TibDateTime is equivalent to the method's argument
        - `false` otherwise (including when the argument is not a TibDateTime instance)

    - #### toString

          public java.lang.String toString()

      Return a printable string representing this TibDateTime.
      Overrides:
        `toString` in class `java.lang.Object`

    - #### compareTo

          public int compareTo(java.lang.Object obj)

      Compare this TibDateTime object to the method's argument.
      Specified by:
        `compareTo` in interface `java.lang.Comparable<java.lang.Object>`
      Parameters:
        `obj` - The second object in the comparison.
      Returns:
        - 1 when this TibDateTime is greater than (later than) the method's argument
        - 0 when this TibDateTime is equal to the method's argument
        - -1 when this TibDateTime is less than (earlier than) the method's argument
      Throws:
        `java.lang.ClassCastException` - if the method's argument is not a TibDateTime instance.