- java.lang.Object
-
- com.pervasive.datarush.tokens.scalar.TimestampToken
-
- All Implemented Interfaces:
DataToken,ScalarToken,ScalarValued,TimestampValued,TokenValued,ScalarTyped,TokenTyped,Serializable,Comparable<TimestampToken>
public final class TimestampToken extends Object implements ScalarToken, Comparable<TimestampToken>
An immutableTimestampValuedobject.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static TimestampTokenNULLA null valuedTimestampTokenstatic TimestampTokenZEROA zero valuedTimestampToken
-
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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longasEpochSecs()Gets the contained timestamp value as the number of seconds since Java epoch (January 1, 1970 00:00:00 GMT).TimestampasTimestamp()Gets the contained timestamp value as ajava.sql.Timestamprelative to the default time zone.intcompareTo(TimestampToken that)booleanequals(Object obj)Indicates whether another object is equal to this token.protected com.pervasive.datarush.tokens.scalar.TimestampParsergetParser()Get the cached parser used by this object.ScalarTokenTypegetType()Gets the data type of the token.inthashCode()Returns a hash code for the token.booleanisNull()Indicates whether the token is null valued.booleanisZero()Indicates whether the value is the zero value for the type.intoffsetSecs()Gets the time zone and daylight saving time offset of the contained timestamp value, in seconds.static TimestampTokenparse(String value)Converts a string representation of a timestamp value into a token.intsubsecNanos()Gets the subsecond portion of the contained timestamp value.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.pervasive.datarush.tokens.scalar.ScalarValued
getType, isZero
-
Methods inherited from interface com.pervasive.datarush.tokens.TokenValued
isNull
-
-
-
-
Field Detail
-
NULL
public static final TimestampToken NULL
A null valuedTimestampToken
-
ZERO
public static final TimestampToken ZERO
A zero valuedTimestampToken
-
-
Constructor Detail
-
TimestampToken
public TimestampToken(TimestampValued value)
Constructs a new token with the timestamp value in the given container.- Parameters:
value- aTimestampValuedcontaining 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, useNULL.- Parameters:
epochSecs- number of seconds since Java epochsubsecNanos- fractional portion of epoch time in nanosecondsoffsetSecs- time zone and daylight saving time offset in seconds
-
-
Method Detail
-
equals
public boolean equals(Object obj)
Description copied from interface:DataTokenIndicates whether another object is equal to this token. Two null valued tokens are considered equal. This differs from the behavior ofTokenComparator.equal(TokenValued,TokenValued)but makes it possible to storeDataTokens inMaps.
-
hashCode
public int hashCode()
Description copied from interface:DataTokenReturns a hash code for the token. This value is guaranteed to be consistent with that returned byTokenConverter.asHashCode(TokenValued).
-
compareTo
public int compareTo(TimestampToken that)
- Specified by:
compareToin interfaceComparable<TimestampToken>
-
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
-
getType
public final ScalarTokenType getType()
Description copied from interface:TokenValuedGets the data type of the token. This type will dictate the valid values that can be contained.- Specified by:
getTypein interfaceScalarTyped- Specified by:
getTypein interfaceScalarValued- Specified by:
getTypein interfaceTokenTyped- Specified by:
getTypein interfaceTokenValued- Returns:
- the token type.
-
asEpochSecs
public final long asEpochSecs()
Description copied from interface:TimestampValuedGets 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, usesubsecNanos()in conjunction with this method.- Specified by:
asEpochSecsin interfaceTimestampValued- Returns:
- the contained value as days since Java epoch.
If null valued, as indicated by
TokenValued.isNull(),0is returned. - See Also:
TimestampValued.subsecNanos()
-
subsecNanos
public final int subsecNanos()
Description copied from interface:TimestampValuedGets the subsecond portion of the contained timestamp value. The value returned is relative to the seconds value returned byasEpochSecs(). Thus the valueasEpochSecs() * 1000000000 + subsecNanos()represents the number of nanoseconds since Java epoch.- Specified by:
subsecNanosin interfaceTimestampValued- Returns:
- the subsecond portion of the contained value, in
nanoseconds. If null valued, as indicated by
TokenValued.isNull(),0is returned. - See Also:
TimestampValued.asEpochSecs()
-
offsetSecs
public final int offsetSecs()
Description copied from interface:TimestampValuedGets the time zone and daylight saving time offset of the contained timestamp value, in seconds.- Specified by:
offsetSecsin interfaceTimestampValued- Returns:
- the time zone and daylight saving time offset of the
contained value, in seconds. If null valued, as indicated by
TokenValued.isNull(),0is returned. - See Also:
TimestampValued.asEpochSecs()
-
asTimestamp
public final Timestamp asTimestamp()
Description copied from interface:TimestampValuedGets the contained timestamp value as ajava.sql.Timestamprelative to the default time zone. The time zone used byTimeZone#getDefault()is used.- Specified by:
asTimestampin interfaceTimestampValued- Returns:
- the contained value as a
java.sql.Timestamp. If null valued, as indicated byTokenValued.isNull(),nullis 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:ScalarValuedIndicates whether the value is the zero value for the type. Zero values are not stored in sparse representation formats.- Specified by:
isZeroin interfaceScalarValued- Returns:
trueif the value is the zero value,falseotherwise.
-
isNull
public final boolean isNull()
Description copied from interface:TokenValuedIndicates 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:
isNullin interfaceTokenValued- Returns:
trueif the token is null valued,falseotherwise
-
-