Package com.webmethods.rtl.date
Class DateFields
java.lang.Object
com.webmethods.rtl.date.DateFields
- All Implemented Interfaces:
Serializable
,Comparable
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
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlong
Increment fields of date according to values in this DateFields object.void
clear()
Remove all valuesint
compareTo
(DateFields df) Compares this DateFields object to the one passed in.int
Of object is a DataFields behaves like compareTo(DateFields).boolean
boolean
equalsByIsSet
(DateFields df, boolean ignoreTime) Two DateFields are equls by isSet if the the same fields are set / not set.boolean
boolean
equalsByIsZero
(DateFields df, boolean ignoreTime) Two DateFields are equls by isZero if the the same fields are zero / not zero.format()
Generate text representation of these date fields.int
get
(int field) Get the value of a fieldstatic String
getFieldName
(int i) Returns text describing the name of a fieldboolean
isSet()
Checks if any field has a value.boolean
isSet
(int field) Checks a field to see if it has a value.boolean
isZero()
Checks if any field has a non-zero value.boolean
isZero
(int field) Checks a field to see if it has a non-zero value.boolean
overlaps
(DateFields other) static DateFields
Parse ISO8601 date-time format.Set fields of date to value of fields from this object.void
set
(int field, int value) Set the value of a fieldlong
substractFromDate
(Date date) Substract fields of date according to values in this DateFields object.toDate()
Returns Date representation of this DateFields
-
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
Generate text representation of these date fields. -
parse
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
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
Returns Date representation of this DateFields -
substractFromDate
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
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
-
compareTo
Of object is a DataFields behaves like compareTo(DateFields). Otherwise ClassCastException will be thrown.- Specified by:
compareTo
in interfaceComparable
-
compareTo
Compares this DateFields object to the one passed in. -
equalsByIsSet
Two DateFields are equls by isSet if the the same fields are set / not set. -
equalsByIsSet
-
equalsByIsZero
Two DateFields are equls by isZero if the the same fields are zero / not zero. -
equalsByIsZero
-
getFieldName
Returns text describing the name of a field
-