- java.lang.Object
-
- com.pervasive.datarush.tokens.scalar.DateToken
-
- All Implemented Interfaces:
DataToken,DateValued,ScalarToken,ScalarValued,TokenValued,ScalarTyped,TokenTyped,Serializable,Comparable<DateToken>
public final class DateToken extends Object implements ScalarToken, Comparable<DateToken>
An immutableDateValuedobject.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static DateTokenNULLA null valuedDateTokenstatic DateTokenZEROA zero valuedDateTokenstatic longZERO_VALUEThe date representing a zero value, the beginning of Java epoch January 1, 1970.
-
Constructor Summary
Constructors Constructor Description DateToken(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.DateToken(Date date)Deprecated.since 6.1DateToken(Date date, TimeZone tz)Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CalendarDateasCalendarDate()Gets the contained date value.DateasDate()Gets the contained date value as ajava.sql.Daterelative to the default time zone.DateasDate(TimeZone tz)Gets the contained date value as ajava.sql.Daterelative to the given time zone.longasEpochDays()Gets the contained date value as the number of days since Java epoch (January 1, 1970).intcompareTo(DateToken that)booleanequals(Object obj)Indicates whether another object is equal to this token.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.static DateTokenparse(String value)Converts a string representation of a date value into a token.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 DateToken NULL
A null valuedDateToken
-
ZERO_VALUE
public static final long ZERO_VALUE
The date representing a zero value, the beginning of Java epoch January 1, 1970.- See Also:
- Constant Field Values
-
ZERO
public static final DateToken ZERO
A zero valuedDateToken
-
-
Constructor Detail
-
DateToken
public DateToken(DateValued value)
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
public DateToken(CalendarDate date)
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 public DateToken(Date date)
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 time zone as returned byTimeZone.getDefault(). 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 public DateToken(Date date, TimeZone tz)
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 zonetz- the time zone in which the date should be interpreted
-
-
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(DateToken that)
- Specified by:
compareToin interfaceComparable<DateToken>
-
parse
public static DateToken parse(String value)
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
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.
-
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
public final Date asDate()
Description copied from interface:DateValuedGets the contained date value as ajava.sql.Daterelative to the default time zone. The time zone used byTimeZone.getDefault()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
public final Date asDate(TimeZone tz)
Description copied from interface:DateValuedGets the contained date value as ajava.sql.Daterelative to the given time zone.- Specified by:
asDatein interfaceDateValued- Parameters:
tz- the time zone 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
public final CalendarDate 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.
-
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
-
-