Class DateFields

java.lang.Object
com.webmethods.rtl.date.DateFields
All Implemented Interfaces:
Serializable, Comparable

public class DateFields extends Object implements Comparable, Serializable
DateFields is a utility class that mirrors the fields within Calendar. The Calendar class adjusts multiple fields when you modify one field. This DateFields class does not do this - it merely holds the fields for use. DateFields uses the same field constants as Calendar. For example: Calendar.MONTH DateFields has a persistent text representation that follows ISO8601 format.
Example: 2001Y2M3W2FT12:00
  • Y=Year
  • M=Month (1-12)
  • W=Week of Month (1-5)
  • w=Week of Year (1-52)
  • D=Day of Year (1-366)
  • d=Day of Month (1-31)
  • F=Day of Week (1-7)
  • HH:MM:SS - HH is in 24hour time. Seconds are optional. '*' can be used for don't care.
See Also:
  • Constructor Details

    • DateFields

      public DateFields()
  • Method Details

    • clear

      public void clear()
      Remove all values
    • isSet

      public boolean isSet(int field)
      Checks a field to see if it has a value. NOTE: This uses the value of -1 as a marker.
      See Also:
    • isSet

      public boolean isSet()
      Checks if any field has a value. It usually is used to see if the fields are cleared. NOTE: This uses the value of -1 as a marker.
      See Also:
    • isZero

      public boolean isZero(int field)
      Checks a field to see if it has a non-zero value. Unset fields are considered as having a zero value. NOTE: This uses the value of -1 as a marker.
      See Also:
    • isZero

      public boolean isZero()
      Checks if any field has a non-zero value. Unset fields are considered as having a zero value. NOTE: This uses the value of -1 as a marker.
      See Also:
    • set

      public void set(int field, int value)
      Set the value of a field
    • get

      public int get(int field)
      Get the value of a field
    • format

      public String format()
      Generate text representation of these date fields.
    • parse

      public static DateFields parse(String interval)
      Parse ISO8601 date-time format.
      Example: 2001Y2M3W2FT12:00
      • Y=Year
      • M=Month (1-12)
      • W=Week of Month (1-5)
      • w=Week of Year (1-52)
      • D=Day of Year (1-366)
      • d=Day of Month (1-31)
      • F=Day of Week (1-7)
      • HH:MM:SS - HH is in 24hour time. Seconds are optional. '*' can be used for don't care.
    • addToDate

      public long addToDate(Date date)
      Increment fields of date according to values in this DateFields object.
      Parameters:
      date - date to update
      Returns:
      time which is the result of adding the fields to date
    • toDate

      public Date toDate()
      Returns Date representation of this DateFields
    • substractFromDate

      public long substractFromDate(Date date)
      Substract fields of date according to values in this DateFields object.
      Parameters:
      date - date to update
      Returns:
      time which is the result of adding the fields to date
    • put

      public Date put(Date date)
      Set fields of date to value of fields from this object. If a field in this object does not have a value, the field from date is preserved.
    • overlaps

      public boolean overlaps(DateFields other)
    • compareTo

      public int compareTo(Object o)
      Of object is a DataFields behaves like compareTo(DateFields). Otherwise ClassCastException will be thrown.
      Specified by:
      compareTo in interface Comparable
    • compareTo

      public int compareTo(DateFields df)
      Compares this DateFields object to the one passed in.
    • equalsByIsSet

      public boolean equalsByIsSet(DateFields df, boolean ignoreTime)
      Two DateFields are equls by isSet if the the same fields are set / not set.
    • equalsByIsSet

      public boolean equalsByIsSet(DateFields df)
    • equalsByIsZero

      public boolean equalsByIsZero(DateFields df, boolean ignoreTime)
      Two DateFields are equls by isZero if the the same fields are zero / not zero.
    • equalsByIsZero

      public boolean equalsByIsZero(DateFields df)
    • getFieldName

      public static String getFieldName(int i)
      Returns text describing the name of a field