java.lang.Object
com.pervasive.datarush.tokens.scalar.TimestampToken
- All Implemented Interfaces:
DataToken,ScalarToken,ScalarValued,TimestampValued,TokenValued,ScalarTyped,TokenTyped,Serializable,Comparable<TimestampToken>
An immutable
TimestampValued object.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TimestampTokenA null valuedTimestampTokenstatic final TimestampTokenA zero valuedTimestampToken -
Constructor Summary
ConstructorsConstructorDescriptionTimestampToken(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
Modifier and TypeMethodDescriptionfinal longGets the contained timestamp value as the number of seconds since Java epoch (January 1, 1970 00:00:00 GMT).final TimestampGets the contained timestamp value as ajava.sql.Timestamprelative to the default time zone.intcompareTo(TimestampToken that) booleanIndicates whether another object is equal to this token.protected com.pervasive.datarush.tokens.scalar.TimestampParserGet the cached parser used by this object.final ScalarTokenTypegetType()Gets the data type of the token.inthashCode()Returns a hash code for the token.final booleanisNull()Indicates whether the token is null valued.booleanisZero()Indicates whether the value is the zero value for the type.final intGets the time zone and daylight saving time offset of the contained timestamp value, in seconds.static TimestampTokenConverts a string representation of a timestamp value into a token.final intGets the subsecond portion of the contained timestamp value.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.pervasive.datarush.tokens.scalar.ScalarValued
getType, isZeroMethods inherited from interface com.pervasive.datarush.tokens.TokenValued
isNull
-
Field Details
-
NULL
A null valuedTimestampToken -
ZERO
A zero valuedTimestampToken
-
-
Constructor Details
-
TimestampToken
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 Details
-
equals
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
- Specified by:
compareToin interfaceComparable<TimestampToken>
-
parse
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
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:
-
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:
-
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:
-
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
-
toString
-
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
-