Class ExplicitDate
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionExplicitDate
(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. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares an object for equality with this ExplicitDate object.static ExplicitDate
fromCalendar
(Calendar cal, boolean useTime) Constructs a new instance ofExplicitDate
from a given Calendar instance.getDay()
Gets the day part of this ExplicitDate object.getMonth()
Gets the month part of this ExplicitDate object.getTime()
Gets the time part of this ExplicitDate object.getYear()
Gets the year part of this ExplicitDate object.int
hashCode()
The hash code value of this ExplicitDate object.void
Sets the day of this ExplicitDate object to the given value.void
Sets the month of this ExplicitDate object to the given value.void
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.Populates this fields of thisExplicitDate
into an instance of Calendar.toCalendar
(Calendar cal) Populates values from thisExplicitDate
instance into the given instance of Calendar.toCalendar
(TimeZone tz) Populates this fields of thisExplicitDate
into an instance of Calendar with a specified time zone.
-
Constructor Details
-
ExplicitDate
public 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. This leaves the time part asnull
.- Parameters:
year
- the year part for this new instance.month
- the month part for this new instance.day
- the day part for this new instance.
-
ExplicitDate
public 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.- Parameters:
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.
-
-
Method Details
-
fromCalendar
Constructs a new instance ofExplicitDate
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.
- Parameters:
cal
- instance of Calendar from which a new instance ofExplicitDate
will be constructed.useTime
- flag indicating whether the hour, minute, and second parts should also be consumed or not. Iftrue
, the newExplicitDate
instance will have its time of day part also set from the given Calendar instance. Iffalse
, only year, month and day will be set.- Returns:
- an instance of
ExplicitDate
.
-
toCalendar
Populates this fields of thisExplicitDate
into an instance of Calendar.This method is equivalent to
toCalendar(Calendar.getInstance())
. It callsCalendar.getInstance()
to get a Calendar object and then passes that object totoCalendar(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()
.- Returns:
- an instance of Calender with its fields set as per
this
ExplicitDate
instance.
-
toCalendar
Populates this fields of thisExplicitDate
into an instance of Calendar with a specified time zone.This method is equivalent to
toCalendar(Calendar.getInstance())
. It callsCalendar.getInstance()
to get a Calendar object and then passes that object totoCalendar(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(TimeZone)
.- Parameters:
tz
- the time zone this instance of Calendar is to be created with.- Returns:
- an instance of Calender with its fields set as per
this
ExplicitDate
instance.
-
toCalendar
Populates values from thisExplicitDate
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.
- Parameters:
cal
- the Calendar instance that will be modified with the available fields of this object. Must not benull
.- Returns:
- the modified Calendar instance.
-
getYear
Gets the year part of this ExplicitDate object.- Returns:
- the year represented by this object.
-
setYear
Sets the year of this ExplicitDate object to the given value.- Parameters:
year
- the year to be set for this object.
-
getMonth
Gets the month part of this ExplicitDate object.- Returns:
- the month represented by this object.
-
setMonth
Sets the month of this ExplicitDate object to the given value.- Parameters:
month
- the month to be set for this object.
-
getDay
Gets the day part of this ExplicitDate object.- Returns:
- the day represented by this object.
-
setDay
Sets the day of this ExplicitDate object to the given value.- Parameters:
day
- the day to be set for this object.
-
getTime
Gets the time part of this ExplicitDate object.- Returns:
- the time represented by this object.
-
setTime
Sets the time of this ExplicitDate object to the given value.- Parameters:
time
- the time to be set for this object.
-
equals
Compares an object for equality with this ExplicitDate object. -
hashCode
public int hashCode()The hash code value of this ExplicitDate object.
-