public class ExplicitDate extends Object implements Serializable
Schedule
or Exclusion
.
While the Recurrence
defines a repetition rule, instances of
this class can be used for specifying explicit date/times within
Schedule
and Exclusion
definitions. ExplicitDate
can be constructed by using appropriate fields defined in the
RecurrenceFields
class.
The class provides the ability to define partial date (when compared
with java.util.Calendar
where the time part may or may not be
specified. Also all other fields such as TimeZone
are not defined
for this class. Such explicit dates are required for defining partial
dates to be included or excluded from a Schedule
or an
Exclusion
definition.
When the time is not specified in an ExplicitDate
, the containing
Schedule
and/or Exclusion
computes it appropriately.
Example:
Consider an example Schedule that indicates
every Monday plus on the 17th of August 2006
.
Here the 17th of August 2006 is a partial date since it
does not have the time part specified. This shouldtypically be defined
via an instance of ExplicitDate
class.
Constructor and Description |
---|
ExplicitDate(RecurrenceFields.YEAR year,
RecurrenceFields.MONTH_OF_YEAR month,
RecurrenceFields.DAY_OF_MONTH day)
Constructs a new ExplicitDate with a year, a month and a
day.
|
ExplicitDate(RecurrenceFields.YEAR year,
RecurrenceFields.MONTH_OF_YEAR month,
RecurrenceFields.DAY_OF_MONTH day,
RecurrenceFields.TIME_OF_DAY time)
Constructs a new ExplicitDate with a year, month, day and a time.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Compares an object for equality with this ExplicitDate object.
|
static ExplicitDate |
fromCalendar(Calendar cal,
boolean useTime)
Constructs a new instance of
ExplicitDate from a given
Calendar instance. |
RecurrenceFields.DAY_OF_MONTH |
getDay()
Gets the day part of this ExplicitDate object.
|
RecurrenceFields.MONTH_OF_YEAR |
getMonth()
Gets the month part of this ExplicitDate object.
|
RecurrenceFields.TIME_OF_DAY |
getTime()
Gets the time part of this ExplicitDate object.
|
RecurrenceFields.YEAR |
getYear()
Gets the year part of this ExplicitDate object.
|
int |
hashCode()
The hash code value of this ExplicitDate object.
|
void |
setDay(RecurrenceFields.DAY_OF_MONTH day)
Sets the day of this ExplicitDate object to the given value.
|
void |
setMonth(RecurrenceFields.MONTH_OF_YEAR month)
Sets the month of this ExplicitDate object to the given value.
|
void |
setTime(RecurrenceFields.TIME_OF_DAY time)
Sets the time of this ExplicitDate object to the given value.
|
void |
setYear(RecurrenceFields.YEAR year)
Sets the year of this ExplicitDate object to the given value.
|
Calendar |
toCalendar()
Populates this fields of this
ExplicitDate into an instance
of Calendar. |
Calendar |
toCalendar(Calendar cal)
Populates values from this
ExplicitDate instance into
the given instance of Calendar. |
public ExplicitDate(RecurrenceFields.YEAR year, RecurrenceFields.MONTH_OF_YEAR month, RecurrenceFields.DAY_OF_MONTH day)
null
.year
- the year part for this new instance.month
- the month part for this new instance.day
- the day part for this new instance.public ExplicitDate(RecurrenceFields.YEAR year, RecurrenceFields.MONTH_OF_YEAR month, RecurrenceFields.DAY_OF_MONTH day, RecurrenceFields.TIME_OF_DAY time)
year
- the year part for this new instance.month
- the month part for this new instance.day
- the day part for this new instance.time
- the time part for this new instance.public static ExplicitDate fromCalendar(Calendar cal, boolean useTime)
ExplicitDate
from a given
Calendar instance.
The new instance of ExplicitDate
has its year, month,
day parts extracted from the given Calender instance.
Optionally the hour, minute and second parts are also extracted
from the Calendar if specified.
All other fields such as time zone, milliseconds, etc of the Calendar instance are completely ignored.
cal
- instance of Calendar from which a new instance of
ExplicitDate
will be constructed.useTime
- flag indicating whether the hour, minute, and
second parts should also be consumed or not.
If true
, the new ExplicitDate
instance will have
its time of day part also set from the given Calendar instance.
If false
, only year, month and day will be set.ExplicitDate
.public Calendar toCalendar()
ExplicitDate
into an instance
of Calendar.
This method is equivalent to toCalendar(Calendar.getInstance())
.
It calls Calendar.getInstance()
to get a Calendar object
and then passes that object to ExplicitDate.toCalendar(Calendar)
.
Only those fields available in this instance are used to set fields
of the Calendar object. Other Calendar fields, such as time zone,
are not changed and will reflect the value returned from the call to
Calendar.getInstance()
.
ExplicitDate
instance.public Calendar toCalendar(Calendar cal)
ExplicitDate
instance into
the given instance of Calendar.
The method sets all the fields available in this object into the given Calendar. Remaining fields are left unchanged. For example, if this object does not have TIME_OF_DAY set, then the time parts of the specified Calendar instance are left unchanged.
cal
- the Calendar instance that will be modified with the
available fields of this object. Must not be null
.public RecurrenceFields.YEAR getYear()
public void setYear(RecurrenceFields.YEAR year)
year
- the year to be set for this object.public RecurrenceFields.MONTH_OF_YEAR getMonth()
public void setMonth(RecurrenceFields.MONTH_OF_YEAR month)
month
- the month to be set for this object.public RecurrenceFields.DAY_OF_MONTH getDay()
public void setDay(RecurrenceFields.DAY_OF_MONTH day)
day
- the day to be set for this object.public RecurrenceFields.TIME_OF_DAY getTime()
public void setTime(RecurrenceFields.TIME_OF_DAY time)
time
- the time to be set for this object.public boolean equals(Object obj)