Module ical4j.core

Class DateProperty<T extends Temporal>

All Implemented Interfaces:
Serializable, Comparable<Property>, FluentProperty, Prototype<Property>
Direct Known Subclasses:
Acknowledged, Completed, Created, DtEnd, DtStamp, DtStart, Due, LastModified, RecurrenceId, Trigger, TzUntil

public abstract class DateProperty<T extends Temporal> extends Property
$Id$

Created on 9/07/2005

Base class for properties with a DATE or DATE-TIME value. Note that some sub-classes may only allow either a DATE or a DATE-TIME value, for which additional rules/validation should be specified. Note that generics have been introduced as part of the migration to the new Java Date/Time API. Date properties should now indicate the applicable Temporal type for the property. For example:

  • UTC-based properties should use Instant to represent UTC time
  • Date-only properties should use LocalDate to represent a date value
  • Date-time properties should use ZonedDateTime to represent a date-time value influenced by timezone rules
See Also:
  • Constructor Details

  • Method Details

    • getDate

      public T getDate()
      This method will attempt to dynamically cast the internal Temporal value to the required return value. e.g. LocalDate localDate = dateProperty.getDate();
      Returns:
      Returns the date.
    • setDate

      public void setDate(T date)
      Sets the date value of this property. The timezone and value of this instance will also be updated accordingly.
      Parameters:
      date - The date to set.
    • setValue

      public void setValue(String value) throws DateTimeParseException
      Default setValue() implementation. Allows for either DATE or DATE-TIME values. Note that this method will use the system default zone rules to parse the string value. For parsing string values in a different timezone use TemporalAdapter.parse(String, ZoneId) and setDate(Temporal).
      Specified by:
      setValue in class Property
      Parameters:
      value - a string representation of a DATE or DATE-TIME value
      Throws:
      DateTimeParseException
    • getValue

      public String getValue()
      Specified by:
      getValue in class Content
      Returns:
      the content value
    • setTimeZoneRegistry

      public void setTimeZoneRegistry(TimeZoneRegistry timeZoneRegistry)
    • refreshParameters

      public void refreshParameters()
      Sometimes following a value update the Value and TzId parameters should be updated to reflect the new value. This method will examine the current value and modify these parameters accordingly.
    • setDefaultTimeZone

      public void setDefaultTimeZone(ZoneId defaultTimeZone)
      A default timezone may be specified for interpreting floating DATE-TIME values. In the absence of a default timezone the system default timezone will be used.
      Parameters:
      defaultTimeZone - a timezone identifier
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Property
    • isUtc

      public final boolean isUtc()
      Indicates whether the current date value is specified in UTC time.
      Returns:
      true if the property is in UTC time, otherwise false
    • validate

      public ValidationResult validate() throws ValidationException
      Perform validation on a property.
      Specified by:
      validate in class Property
      Throws:
      ValidationException - where the property is not in a valid state
    • compareTo

      public int compareTo(Property o)
      Specified by:
      compareTo in interface Comparable<T extends Temporal>
      Overrides:
      compareTo in class Property