Class TimestampToken

    • Constructor Summary

      Constructors 
      Constructor Description
      TimestampToken​(long epochSecs, int subsecNanos, int offsetSecs)
      Constructs a new token with the non-null timestamp value specified as the number of seconds since Java epoch (January 1, 1970 00:00:00 GMT).
      TimestampToken​(TimestampValued value)
      Constructs a new token with the timestamp value in the given container.
    • Field Detail

      • NULL

        public static final TimestampToken NULL
        A null valued TimestampToken
      • ZERO

        public static final TimestampToken ZERO
        A zero valued TimestampToken
    • Constructor Detail

      • TimestampToken

        public TimestampToken​(TimestampValued value)
        Constructs a new token with the timestamp value in the given container.
        Parameters:
        value - a TimestampValued containing the desired value
      • TimestampToken

        public TimestampToken​(long epochSecs,
                              int subsecNanos,
                              int offsetSecs)
        Constructs a new token with the non-null timestamp value specified as the number of seconds since Java epoch (January 1, 1970 00:00:00 GMT). Nanosecond precision and originating time zone and daylight saving time offset information may also be provided. If a null valued token is desired, use NULL.
        Parameters:
        epochSecs - number of seconds since Java epoch
        subsecNanos - fractional portion of epoch time in nanoseconds
        offsetSecs - time zone and daylight saving time offset in seconds
    • Method Detail

      • equals

        public boolean equals​(Object obj)
        Description copied from interface: DataToken
        Indicates whether another object is equal to this token. Two null valued tokens are considered equal. This differs from the behavior of TokenComparator.equal(TokenValued,TokenValued) but makes it possible to store DataTokens in Maps.
        Specified by:
        equals in interface DataToken
        Overrides:
        equals in class Object
        Parameters:
        obj - the object to compare
        Returns:
        true if the other object is a token of the same type and contains the same value, false otherwise.
      • hashCode

        public int hashCode()
        Description copied from interface: DataToken
        Returns a hash code for the token. This value is guaranteed to be consistent with that returned by TokenConverter.asHashCode(TokenValued).
        Specified by:
        hashCode in interface DataToken
        Overrides:
        hashCode in class Object
        Returns:
        a hash code value for the token
      • parse

        public static TimestampToken parse​(String value)
        Converts a string representation of a timestamp value into a token.
        Parameters:
        value - a string value to interpret as a timestamp; this must be in ISO8601 format.
        Returns:
        a token with the specified value
      • asEpochSecs

        public final long asEpochSecs()
        Description copied from interface: TimestampValued
        Gets the contained timestamp value as the number of seconds since Java epoch (January 1, 1970 00:00:00 GMT). Timestamp values support nanosecond precision, although this method does not expose it. To access this level of detail, use subsecNanos() in conjunction with this method.
        Specified by:
        asEpochSecs in interface TimestampValued
        Returns:
        the contained value as days since Java epoch. If null valued, as indicated by TokenValued.isNull(), 0 is returned.
        See Also:
        TimestampValued.subsecNanos()
      • subsecNanos

        public final int subsecNanos()
        Description copied from interface: TimestampValued
        Gets the subsecond portion of the contained timestamp value. The value returned is relative to the seconds value returned by asEpochSecs(). Thus the value asEpochSecs() * 1000000000 + subsecNanos() represents the number of nanoseconds since Java epoch.
        Specified by:
        subsecNanos in interface TimestampValued
        Returns:
        the subsecond portion of the contained value, in nanoseconds. If null valued, as indicated by TokenValued.isNull(), 0 is returned.
        See Also:
        TimestampValued.asEpochSecs()
      • offsetSecs

        public final int offsetSecs()
        Description copied from interface: TimestampValued
        Gets the time zone and daylight saving time offset of the contained timestamp value, in seconds.
        Specified by:
        offsetSecs in interface TimestampValued
        Returns:
        the time zone and daylight saving time offset of the contained value, in seconds. If null valued, as indicated by TokenValued.isNull(), 0 is returned.
        See Also:
        TimestampValued.asEpochSecs()
      • asTimestamp

        public final Timestamp asTimestamp()
        Description copied from interface: TimestampValued
        Gets the contained timestamp value as a java.sql.Timestamp relative to the default time zone. The time zone used by TimeZone#getDefault() is used.
        Specified by:
        asTimestamp in interface TimestampValued
        Returns:
        the contained value as a java.sql.Timestamp. If null valued, as indicated by TokenValued.isNull(), null is returned.
      • getParser

        protected com.pervasive.datarush.tokens.scalar.TimestampParser getParser()
        Get the cached parser used by this object.
        Returns:
        the cached parser
      • isZero

        public boolean isZero()
        Description copied from interface: ScalarValued
        Indicates whether the value is the zero value for the type. Zero values are not stored in sparse representation formats.
        Specified by:
        isZero in interface ScalarValued
        Returns:
        true if the value is the zero value, false otherwise.
      • isNull

        public final boolean isNull()
        Description copied from interface: TokenValued
        Indicates whether the token is null valued. Tokens support null values analogous to SQL. Before accessing the value of the container, it is usually best to ensure it is not null valued using this method.
        Specified by:
        isNull in interface TokenValued
        Returns:
        true if the token is null valued, false otherwise