java.lang.Object
com.pervasive.datarush.tokens.scalar.DateToken
- All Implemented Interfaces:
DataToken,DateValued,ScalarToken,ScalarValued,TokenValued,ScalarTyped,TokenTyped,Serializable,Comparable<DateToken>
An immutable
DateValued object.- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDateToken(int year, int monthOfYear, int dayOfMonth) Constructs a new token with the non-null calendar date.DateToken(long epochDays) Constructs a new token with the non-null date value specified as the number of days since Java epoch (January 1, 1970 GMT).DateToken(CalendarDate date) Constructs a new token with the non-null calendar date.DateToken(DateValued value) Constructs a new token with the date value in the given container.Deprecated.since 6.1Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionfinal CalendarDateGets the contained date value.final DateasDate()Gets the contained date value as ajava.sql.Daterelative to the default time zone.final DateGets the contained date value as ajava.sql.Daterelative to the given time zone.final longGets the contained date value as the number of days since Java epoch (January 1, 1970).intbooleanIndicates whether another object is equal to this token.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.final booleanisZero()Indicates whether the value is the zero value for the type.static DateTokenConverts a string representation of a date value into a token.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 valuedDateToken -
ZERO_VALUE
public static final long ZERO_VALUEThe date representing a zero value, the beginning of Java epoch January 1, 1970.- See Also:
-
ZERO
A zero valuedDateToken
-
-
Constructor Details
-
DateToken
Constructs a new token with the date value in the given container.- Parameters:
value- aDateValuedcontaining the desired value
-
DateToken
public DateToken(long epochDays) Constructs a new token with the non-null date value specified as the number of days since Java epoch (January 1, 1970 GMT). If a null valued token is desired, useNULL.- Parameters:
epochDays- the date value of the token, expressed as the number of days since Java epoch
-
DateToken
public DateToken(int year, int monthOfYear, int dayOfMonth) Constructs a new token with the non-null calendar date. If a null valued token is desired, useNULL.- Parameters:
year- the year portion of the calendar datemonthOfYear- the month portion of the calendar date. Months start from1, unlikejava.util.Calendar.dayOfMonth- the day portion of the calendar date.
-
DateToken
Constructs a new token with the non-null calendar date. If a null valued token is desired, useNULL.- Parameters:
date- the calendar date of the token
-
DateToken
Deprecated.since 6.1Constructs a new token with the non-null date value specified as ajava.util.Dateobject. The date is interpreted relative to the default zone id as returned byZoneId.systemDefault(). If a null valued token is desired, useNULL.- Parameters:
date- the date value of the token, expressed as a point in time relative to the default time zone
-
DateToken
Deprecated.Constructs a new token with the non-null date value specified as ajava.util.Dateobject interpreted relative to the given time zone. If a null valued token is desired, useNULL.- Parameters:
date- the date value of the token, expressed as a point in time relative to the specified time zonezoneId- the time zone id in which the date should be interpreted
-
-
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<DateToken>
-
parse
Converts a string representation of a date value into a token.- Parameters:
value- a string value to interpret as a date; 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.
-
asEpochDays
public final long asEpochDays()Description copied from interface:DateValuedGets the contained date value as the number of days since Java epoch (January 1, 1970).- Specified by:
asEpochDaysin interfaceDateValued- Returns:
- the contained value as days since Java epoch.
If null valued, as indicated by
TokenValued.isNull(),0is returned.
-
asDate
Description copied from interface:DateValuedGets the contained date value as ajava.sql.Daterelative to the default time zone. The time zone id used by {@link ZoneId.systemDefault()} is used.- Specified by:
asDatein interfaceDateValued- Returns:
- the contained value as a
java.sql.Date. If null valued, as indicated byTokenValued.isNull(),nullis returned.
-
asDate
Description copied from interface:DateValuedGets the contained date value as ajava.sql.Daterelative to the given time zone.- Specified by:
asDatein interfaceDateValued- Parameters:
zoneId- the time zone id in which to interpret the date- Returns:
- the contained value as a
java.sql.Date. If null valued, as indicated byTokenValued.isNull(),nullis returned.
-
asCalendarDate
Description copied from interface:DateValuedGets the contained date value. This value represents the timezone free date portion of a timestamp.- Specified by:
asCalendarDatein interfaceDateValued- Returns:
- the contained value as a calendar date.
If null valued, as indicated by
TokenValued.isNull(),nullis returned.
-
isZero
public final 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.
-
toString
-
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
-