Class DateValue

  • All Implemented Interfaces:
    Value

    public class DateValue
    extends BaseValue
    A DateValue provides an implementation of the Value interface representing a date value.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int TYPE  
    • Constructor Summary

      Constructors 
      Constructor Description
      DateValue​(java.util.Calendar date)
      Constructs a DateValue object representing a date.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)
      Indicates whether some other object is "equal to" this one.
      boolean getBoolean()
      Returns a Boolean representation of this value.
      java.util.Calendar getDate()
      Returns a Calendar representation of this value.
      java.math.BigDecimal getDecimal()
      Returns a BigDecimal representation of this value.
      double getDouble()
      Returns a double representation of this value.
      long getLong()
      Returns a long representation of this value.
      int hashCode()
      Returns zero to satisfy the Object equals/hashCode contract.
      static DateValue valueOf​(java.lang.String s)
      Returns a new DateValue initialized to the value represented by the specified String.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DateValue

        public DateValue​(java.util.Calendar date)
                  throws java.lang.IllegalArgumentException
        Constructs a DateValue object representing a date.
        Parameters:
        date - the date this DateValue should represent
        Throws:
        java.lang.IllegalArgumentException - if the given date cannot be represented as defined by ISO 8601.
    • Method Detail

      • valueOf

        public static DateValue valueOf​(java.lang.String s)
                                 throws ValueFormatException
        Returns a new DateValue initialized to the value represented by the specified String.

        The specified String must be a ISO8601-compliant date/time string.

        Parameters:
        s - the string to be parsed.
        Returns:
        a newly constructed DateValue representing the the specified value.
        Throws:
        ValueFormatException - If the String is not a valid ISO8601-compliant date/time string.
        See Also:
        ISO8601
      • equals

        public boolean equals​(java.lang.Object obj)
        Indicates whether some other object is "equal to" this one.

        The result is true if and only if the argument is not null and is a DateValue object that represents the same value as this object.

        The value comparison is performed using the ISO 8601 string representation of the dates, since the native Calendar.equals() method may produce false negatives (see JSR-598).

        Note that the comparison still returns false when comparing the same time in different time zones, but that seems to be the intent of JSR 170. Compare the Value.getDate().getTime() values if you need an exact time comparison in UTC.

        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the reference object with which to compare.
        Returns:
        true if this object is the same as the obj argument; false otherwise.
      • hashCode

        public int hashCode()
        Returns zero to satisfy the Object equals/hashCode contract. This class is mutable and not meant to be used as a hash key.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        always zero
        See Also:
        Object.hashCode()
      • getDate

        public java.util.Calendar getDate()
                                   throws ValueFormatException,
                                          java.lang.IllegalStateException,
                                          RepositoryException
        Returns a Calendar representation of this value.

        The object returned is a copy of the stored value, so changes to it are not reflected in internal storage.

        Specified by:
        getDate in interface Value
        Overrides:
        getDate in class BaseValue
        Returns:
        A Calendar representation of this value.
        Throws:
        ValueFormatException - if conversion to a Calendar is not possible.
        RepositoryException - if another error occurs.
        java.lang.IllegalStateException