Class DateToken

    • Field Detail

      • NULL

        public static final DateToken NULL
        A null valued DateToken
      • 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 valued DateToken
    • Constructor Detail

      • DateToken

        public DateToken​(DateValued value)
        Constructs a new token with the date value in the given container.
        Parameters:
        value - a DateValued containing 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, use NULL.
        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, use NULL.
        Parameters:
        year - the year portion of the calendar date
        monthOfYear - the month portion of the calendar date. Months start from 1, unlike java.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, use NULL.
        Parameters:
        date - the calendar date of the token
      • DateToken

        @Deprecated
        public DateToken​(Date date)
        Deprecated.
        since 6.1
        Constructs a new token with the non-null date value specified as a 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.
        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 a java.util.Date object interpreted relative to the given time zone. If a null valued token is desired, use NULL.
        Parameters:
        date - the date value of the token, expressed as a point in time relative to the specified time zone
        tz - the time zone in which the date should be interpreted
    • Method Detail

      • equals

        public boolean equals​(Object obj)
        Description copied from interface: DataToken
        Indicates whether another object is equal to this token. Two null valued tokens are considered equal. This differs from the behavior of TokenComparator.equal(TokenValued,TokenValued) but makes it possible to store DataTokens in Maps.
        Specified by:
        equals in interface DataToken
        Overrides:
        equals in class Object
        Parameters:
        obj - the object to compare
        Returns:
        true if the other object is a token of the same type and contains the same value, false otherwise.
      • hashCode

        public int hashCode()
        Description copied from interface: DataToken
        Returns a hash code for the token. This value is guaranteed to be consistent with that returned by TokenConverter.asHashCode(TokenValued).
        Specified by:
        hashCode in interface DataToken
        Overrides:
        hashCode in class Object
        Returns:
        a hash code value for the token
      • 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
      • asEpochDays

        public final long asEpochDays()
        Description copied from interface: DateValued
        Gets the contained date value as the number of days since Java epoch (January 1, 1970).
        Specified by:
        asEpochDays in interface DateValued
        Returns:
        the contained value as days since Java epoch. If null valued, as indicated by TokenValued.isNull(), 0 is returned.
      • asDate

        public final Date asDate()
        Description copied from interface: DateValued
        Gets the contained date value as a java.sql.Date relative to the default time zone. The time zone used by TimeZone.getDefault() is used.
        Specified by:
        asDate in interface DateValued
        Returns:
        the contained value as a java.sql.Date. If null valued, as indicated by TokenValued.isNull(), null is returned.
      • asDate

        public final Date asDate​(TimeZone tz)
        Description copied from interface: DateValued
        Gets the contained date value as a java.sql.Date relative to the given time zone.
        Specified by:
        asDate in interface DateValued
        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 by TokenValued.isNull(), null is returned.
      • asCalendarDate

        public final CalendarDate asCalendarDate()
        Description copied from interface: DateValued
        Gets the contained date value. This value represents the timezone free date portion of a timestamp.
        Specified by:
        asCalendarDate in interface DateValued
        Returns:
        the contained value as a calendar date. If null valued, as indicated by TokenValued.isNull(), null is returned.
      • isZero

        public final boolean isZero()
        Description copied from interface: ScalarValued
        Indicates whether the value is the zero value for the type. Zero values are not stored in sparse representation formats.
        Specified by:
        isZero in interface ScalarValued
        Returns:
        true if the value is the zero value, false otherwise.
      • isNull

        public final boolean isNull()
        Description copied from interface: TokenValued
        Indicates 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:
        isNull in interface TokenValued
        Returns:
        true if the token is null valued, false otherwise