public final class DateToken extends Object implements ScalarToken, Comparable<DateToken>
DateValued
object.Modifier and Type | Field and Description |
---|---|
static DateToken |
NULL
A null valued
DateToken |
static DateToken |
ZERO
A zero valued
DateToken |
static long |
ZERO_VALUE
The date representing a zero value, the beginning of Java epoch January 1, 1970.
|
Constructor and Description |
---|
DateToken(CalendarDate date)
Constructs a new token with the non-null calendar date.
|
DateToken(Date date)
Deprecated.
since 6.1
|
DateToken(Date date,
TimeZone tz)
Deprecated.
|
DateToken(DateValued value)
Constructs a new token with the date
value in the given container.
|
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).
|
Modifier and Type | Method and Description |
---|---|
CalendarDate |
asCalendarDate()
Gets the contained date value.
|
Date |
asDate()
Gets the contained date value as a
java.sql.Date
relative to the default time zone. |
Date |
asDate(TimeZone tz)
Gets the contained date value as a
java.sql.Date
relative to the given time zone. |
long |
asEpochDays()
Gets the contained date value as the number of days since
Java epoch (January 1, 1970).
|
int |
compareTo(DateToken that) |
boolean |
equals(Object obj)
Indicates whether another object is equal to this token.
|
ScalarTokenType |
getType()
Gets the data type of the token.
|
int |
hashCode()
Returns a hash code for the token.
|
boolean |
isNull()
Indicates whether the token is null valued.
|
boolean |
isZero()
Indicates whether the value is the zero value
for the type.
|
static DateToken |
parse(String value)
Converts a string representation of a date value into
a token.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getType, isZero
isNull
public static final DateToken NULL
DateToken
public static final long ZERO_VALUE
public static final DateToken ZERO
DateToken
public DateToken(DateValued value)
value
- a DateValued
containing the
desired valuepublic DateToken(long epochDays)
NULL
.epochDays
- the date value of the token, expressed as the
number of days since Java epochpublic DateToken(int year, int monthOfYear, int dayOfMonth)
NULL
.year
- the year portion of the calendar datemonthOfYear
- the month portion of the calendar date. Months
start from 1
, unlike java.util.Calendar
.dayOfMonth
- the day portion of the calendar date.public DateToken(CalendarDate date)
NULL
.date
- the calendar date of the token@Deprecated public DateToken(Date date)
java.util.Date
object. The date
is interpreted relative to the default time zone as returned
by TimeZone.getDefault()
.
If a null valued token is desired, use NULL
.date
- the date value of the token, expressed as a
point in time relative to the default time zone@Deprecated public DateToken(Date date, TimeZone tz)
java.util.Date
object interpreted
relative to the given time zone.
If a null valued token is desired, use NULL
.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 interpretedpublic boolean equals(Object obj)
DataToken
TokenComparator.equal(TokenValued,TokenValued)
but makes it possible to store DataToken
s in Map
s.public int hashCode()
DataToken
TokenConverter.asHashCode(TokenValued)
.public int compareTo(DateToken that)
compareTo
in interface Comparable<DateToken>
public static DateToken parse(String value)
value
- a string value to interpret as a date;
this must be in ISO8601 format.public final ScalarTokenType getType()
TokenValued
getType
in interface ScalarValued
getType
in interface TokenValued
getType
in interface ScalarTyped
getType
in interface TokenTyped
public final long asEpochDays()
DateValued
asEpochDays
in interface DateValued
TokenValued.isNull()
,
0
is returned.public final Date asDate()
DateValued
java.sql.Date
relative to the default time zone. The time zone used by
TimeZone.getDefault()
is used.asDate
in interface DateValued
java.sql.Date
.
If null valued, as indicated by TokenValued.isNull()
,
null
is returned.public final Date asDate(TimeZone tz)
DateValued
java.sql.Date
relative to the given time zone.asDate
in interface DateValued
tz
- the time zone in which to interpret the datejava.sql.Date
.
If null valued, as indicated by TokenValued.isNull()
,
null
is returned.public final CalendarDate asCalendarDate()
DateValued
asCalendarDate
in interface DateValued
TokenValued.isNull()
,
null
is returned.public final boolean isZero()
ScalarValued
isZero
in interface ScalarValued
true
if the value is the zero value,
false
otherwise.public final boolean isNull()
TokenValued
isNull
in interface TokenValued
true
if the token is null valued,
false
otherwiseCopyright © 2024 Actian Corporation. All rights reserved.