Class DailyCalendar
- java.lang.Object
-
- org.quartz.impl.calendar.BaseCalendar
-
- org.quartz.impl.calendar.DailyCalendar
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,Calendar
public class DailyCalendar extends BaseCalendar
This implementation of the Calendar excludes (or includes - see below) a specified time range each day. For example, you could use this calendar to exclude business hours (8AM - 5PM) every day. EachDailyCalendar
only allows a single time range to be specified, and that time range may not cross daily boundaries (i.e. you cannot specify a time range from 8PM - 5AM). If the propertyinvertTimeRange
isfalse
(default), the time range defines a range of times in which triggers are not allowed to fire. IfinvertTimeRange
istrue
, the time range is inverted – that is, all times outside the defined time range are excluded.Note when using
DailyCalendar
, it behaves on the same principals as, for example,WeeklyCalendar
.WeeklyCalendar
defines a set of days that are excluded every week. Likewise,DailyCalendar
defines a set of times that are excluded every day.- Author:
- Mike Funk, Aaron Craven
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DailyCalendar(int rangeStartingHourOfDay, int rangeStartingMinute, int rangeStartingSecond, int rangeStartingMillis, int rangeEndingHourOfDay, int rangeEndingMinute, int rangeEndingSecond, int rangeEndingMillis)
Create aDailyCalendar
with a time range defined by the specified values and nobaseCalendar
.DailyCalendar(long rangeStartingTimeInMillis, long rangeEndingTimeInMillis)
Create aDailyCalendar
with a time range defined by the specified values and nobaseCalendar
.DailyCalendar(java.lang.String rangeStartingTime, java.lang.String rangeEndingTime)
Create aDailyCalendar
with a time range defined by the specified strings and nobaseCalendar
.DailyCalendar(java.util.Calendar rangeStartingCalendar, java.util.Calendar rangeEndingCalendar)
Create aDailyCalendar
with a time range defined by the specifiedjava.util.Calendar
s and nobaseCalendar
.DailyCalendar(java.util.TimeZone timeZone, long rangeStartingTimeInMillis, long rangeEndingTimeInMillis)
Create aDailyCalendar
with a time range defined by the specified values and nobaseCalendar
.DailyCalendar(Calendar baseCalendar, int rangeStartingHourOfDay, int rangeStartingMinute, int rangeStartingSecond, int rangeStartingMillis, int rangeEndingHourOfDay, int rangeEndingMinute, int rangeEndingSecond, int rangeEndingMillis)
Create aDailyCalendar
with a time range defined by the specified values and the specifiedbaseCalendar
.DailyCalendar(Calendar baseCalendar, long rangeStartingTimeInMillis, long rangeEndingTimeInMillis)
Create aDailyCalendar
with a time range defined by the specified values and the specifiedbaseCalendar
.DailyCalendar(Calendar baseCalendar, java.lang.String rangeStartingTime, java.lang.String rangeEndingTime)
Create aDailyCalendar
with a time range defined by the specified strings and the specifiedbaseCalendar
.DailyCalendar(Calendar baseCalendar, java.util.Calendar rangeStartingCalendar, java.util.Calendar rangeEndingCalendar)
Create aDailyCalendar
with a time range defined by the specifiedjava.util.Calendar
s and the specifiedbaseCalendar
.DailyCalendar(Calendar baseCalendar, java.util.TimeZone timeZone, long rangeStartingTimeInMillis, long rangeEndingTimeInMillis)
Create aDailyCalendar
with a time range defined by the specified values and the specifiedbaseCalendar
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
boolean
getInvertTimeRange()
Indicates whether the time range represents an inverted time range (see class description).long
getNextIncludedTime(long timeInMillis)
Determines the next time included by theDailyCalendar
after the specified time.long
getTimeRangeEndingTimeInMillis(long timeInMillis)
Returns the end time of the time range (in milliseconds) of the day specified intimeInMillis
long
getTimeRangeStartingTimeInMillis(long timeInMillis)
Returns the start time of the time range (in milliseconds) of the day specified intimeInMillis
boolean
isTimeIncluded(long timeInMillis)
Determines whether the given time (in milliseconds) is 'included' by theBaseCalendar
void
setInvertTimeRange(boolean flag)
Indicates whether the time range represents an inverted time range (see class description).void
setTimeRange(int rangeStartingHourOfDay, int rangeStartingMinute, int rangeStartingSecond, int rangeStartingMillis, int rangeEndingHourOfDay, int rangeEndingMinute, int rangeEndingSecond, int rangeEndingMillis)
Sets the time range for theDailyCalendar
to the times represented in the specified values.void
setTimeRange(long rangeStartingTime, long rangeEndingTime)
Sets the time range for theDailyCalendar
to the times represented in the specified values.void
setTimeRange(java.lang.String rangeStartingTimeString, java.lang.String rangeEndingTimeString)
Sets the time range for theDailyCalendar
to the times represented in the specified Strings.void
setTimeRange(java.util.Calendar rangeStartingCalendar, java.util.Calendar rangeEndingCalendar)
Sets the time range for theDailyCalendar
to the times represented in the specifiedjava.util.Calendar
s.java.lang.String
toString()
Returns a string representing the properties of theDailyCalendar
-
Methods inherited from class org.quartz.impl.calendar.BaseCalendar
createJavaCalendar, createJavaCalendar, getBaseCalendar, getDescription, getEndOfDayJavaCalendar, getStartOfDayJavaCalendar, getTimeZone, setBaseCalendar, setDescription, setTimeZone
-
-
-
-
Constructor Detail
-
DailyCalendar
public DailyCalendar(java.lang.String rangeStartingTime, java.lang.String rangeEndingTime)
Create aDailyCalendar
with a time range defined by the specified strings and nobaseCalendar
.rangeStartingTime
andrangeEndingTime
must be in the format "HH:MM[:SS[:mmm]]" where:- HH is the hour of the specified time. The hour should be specified using military (24-hour) time and must be in the range 0 to 23.
- MM is the minute of the specified time and must be in the range 0 to 59.
- SS is the second of the specified time and must be in the range 0 to 59.
- mmm is the millisecond of the specified time and must be in the range 0 to 999.
- items enclosed in brackets ('[', ']') are optional.
- The time range starting time must be before the time range ending time. Note this means that a time range may not cross daily boundaries (10PM - 2AM)
Note: This
DailyCalendar
will use the
time zone unless an explicit time zone is set viaTimeZone.getDefault()
BaseCalendar.setTimeZone(TimeZone)
- Parameters:
rangeStartingTime
- a String representing the starting time for the time rangerangeEndingTime
- a String representing the ending time for the the time range
-
DailyCalendar
public DailyCalendar(Calendar baseCalendar, java.lang.String rangeStartingTime, java.lang.String rangeEndingTime)
Create aDailyCalendar
with a time range defined by the specified strings and the specifiedbaseCalendar
.rangeStartingTime
andrangeEndingTime
must be in the format "HH:MM[:SS[:mmm]]" where:- HH is the hour of the specified time. The hour should be specified using military (24-hour) time and must be in the range 0 to 23.
- MM is the minute of the specified time and must be in the range 0 to 59.
- SS is the second of the specified time and must be in the range 0 to 59.
- mmm is the millisecond of the specified time and must be in the range 0 to 999.
- items enclosed in brackets ('[', ']') are optional.
- The time range starting time must be before the time range ending time. Note this means that a time range may not cross daily boundaries (10PM - 2AM)
Note: This
DailyCalendar
will use the
time zone unless an explicit time zone is set viaTimeZone.getDefault()
BaseCalendar.setTimeZone(TimeZone)
- Parameters:
baseCalendar
- the base calendar for this calendar instance – seeBaseCalendar
for more information on base calendar functionalityrangeStartingTime
- a String representing the starting time for the time rangerangeEndingTime
- a String representing the ending time for the time range
-
DailyCalendar
public DailyCalendar(int rangeStartingHourOfDay, int rangeStartingMinute, int rangeStartingSecond, int rangeStartingMillis, int rangeEndingHourOfDay, int rangeEndingMinute, int rangeEndingSecond, int rangeEndingMillis)
Create aDailyCalendar
with a time range defined by the specified values and nobaseCalendar
. Values are subject to the following validations:- Hours must be in the range 0-23 and are expressed using military (24-hour) time.
- Minutes must be in the range 0-59
- Seconds must be in the range 0-59
- Milliseconds must be in the range 0-999
- The time range starting time must be before the time range ending time. Note this means that a time range may not cross daily boundaries (10PM - 2AM)
Note: This
DailyCalendar
will use the
time zone unless an explicit time zone is set viaTimeZone.getDefault()
BaseCalendar.setTimeZone(TimeZone)
- Parameters:
rangeStartingHourOfDay
- the hour of the start of the time rangerangeStartingMinute
- the minute of the start of the time rangerangeStartingSecond
- the second of the start of the time rangerangeStartingMillis
- the millisecond of the start of the time rangerangeEndingHourOfDay
- the hour of the end of the time rangerangeEndingMinute
- the minute of the end of the time rangerangeEndingSecond
- the second of the end of the time rangerangeEndingMillis
- the millisecond of the start of the time range
-
DailyCalendar
public DailyCalendar(Calendar baseCalendar, int rangeStartingHourOfDay, int rangeStartingMinute, int rangeStartingSecond, int rangeStartingMillis, int rangeEndingHourOfDay, int rangeEndingMinute, int rangeEndingSecond, int rangeEndingMillis)
Create aDailyCalendar
with a time range defined by the specified values and the specifiedbaseCalendar
. Values are subject to the following validations:- Hours must be in the range 0-23 and are expressed using military (24-hour) time.
- Minutes must be in the range 0-59
- Seconds must be in the range 0-59
- Milliseconds must be in the range 0-999
- The time range starting time must be before the time range ending time. Note this means that a time range may not cross daily boundaries (10PM - 2AM)
Note: This
DailyCalendar
will use the
time zone unless an explicit time zone is set viaTimeZone.getDefault()
BaseCalendar.setTimeZone(TimeZone)
- Parameters:
baseCalendar
- the base calendar for this calendar instance – seeBaseCalendar
for more information on base calendar functionalityrangeStartingHourOfDay
- the hour of the start of the time rangerangeStartingMinute
- the minute of the start of the time rangerangeStartingSecond
- the second of the start of the time rangerangeStartingMillis
- the millisecond of the start of the time rangerangeEndingHourOfDay
- the hour of the end of the time rangerangeEndingMinute
- the minute of the end of the time rangerangeEndingSecond
- the second of the end of the time rangerangeEndingMillis
- the millisecond of the start of the time range
-
DailyCalendar
public DailyCalendar(java.util.Calendar rangeStartingCalendar, java.util.Calendar rangeEndingCalendar)
Create aDailyCalendar
with a time range defined by the specifiedjava.util.Calendar
s and nobaseCalendar
. The Calendars are subject to the following considerations:- Only the time-of-day fields of the specified Calendars will be used (the date fields will be ignored)
- The starting time must be before the ending time of the defined
time range. Note this means that a time range may not cross
daily boundaries (10PM - 2AM). (because only time fields are
are used, it is possible for two Calendars to represent a valid
time range and
rangeStartingCalendar.after(rangeEndingCalendar) == true
)
Note: This
DailyCalendar
will use the
time zone unless an explicit time zone is set viaTimeZone.getDefault()
BaseCalendar.setTimeZone(TimeZone)
- Parameters:
rangeStartingCalendar
- a java.util.Calendar representing the starting time for the time rangerangeEndingCalendar
- a java.util.Calendar representing the ending time for the time range
-
DailyCalendar
public DailyCalendar(Calendar baseCalendar, java.util.Calendar rangeStartingCalendar, java.util.Calendar rangeEndingCalendar)
Create aDailyCalendar
with a time range defined by the specifiedjava.util.Calendar
s and the specifiedbaseCalendar
. The Calendars are subject to the following considerations:- Only the time-of-day fields of the specified Calendars will be used (the date fields will be ignored)
- The starting time must be before the ending time of the defined
time range. Note this means that a time range may not cross
daily boundaries (10PM - 2AM). (because only time fields are
are used, it is possible for two Calendars to represent a valid
time range and
rangeStartingCalendar.after(rangeEndingCalendar) == true
)
Note: This
DailyCalendar
will use the
time zone unless an explicit time zone is set viaTimeZone.getDefault()
BaseCalendar.setTimeZone(TimeZone)
- Parameters:
baseCalendar
- the base calendar for this calendar instance – seeBaseCalendar
for more information on base calendar functionalityrangeStartingCalendar
- a java.util.Calendar representing the starting time for the time rangerangeEndingCalendar
- a java.util.Calendar representing the ending time for the time range
-
DailyCalendar
public DailyCalendar(long rangeStartingTimeInMillis, long rangeEndingTimeInMillis)
Create aDailyCalendar
with a time range defined by the specified values and nobaseCalendar
. The values are subject to the following considerations:- Only the time-of-day portion of the specified values will be used
- The starting time must be before the ending time of the defined
time range. Note this means that a time range may not cross
daily boundaries (10PM - 2AM). (because only time value are
are used, it is possible for the two values to represent a valid
time range and
rangeStartingTime > rangeEndingTime
)
Note: This
DailyCalendar
will use the
time zone unless an explicit time zone is set viaTimeZone.getDefault()
. You should useBaseCalendar.setTimeZone(TimeZone)
if you don't want the givenDailyCalendar(org.quartz.Calendar, java.util.TimeZone, long, long)
rangeStartingTimeInMillis
andrangeEndingTimeInMillis
to be evaluated in the default time zone.- Parameters:
rangeStartingTimeInMillis
- a long representing the starting time for the time rangerangeEndingTimeInMillis
- a long representing the ending time for the time range
-
DailyCalendar
public DailyCalendar(Calendar baseCalendar, long rangeStartingTimeInMillis, long rangeEndingTimeInMillis)
Create aDailyCalendar
with a time range defined by the specified values and the specifiedbaseCalendar
. The values are subject to the following considerations:- Only the time-of-day portion of the specified values will be used
- The starting time must be before the ending time of the defined
time range. Note this means that a time range may not cross
daily boundaries (10PM - 2AM). (because only time value are
are used, it is possible for the two values to represent a valid
time range and
rangeStartingTime > rangeEndingTime
)
Note: This
DailyCalendar
will use the
time zone unless an explicit time zone is set viaTimeZone.getDefault()
. You should useBaseCalendar.setTimeZone(TimeZone)
if you don't want the givenDailyCalendar(org.quartz.Calendar, java.util.TimeZone, long, long)
rangeStartingTimeInMillis
andrangeEndingTimeInMillis
to be evaluated in the default time zone.- Parameters:
baseCalendar
- the base calendar for this calendar instance – seeBaseCalendar
for more information on base calendar functionalityrangeStartingTimeInMillis
- a long representing the starting time for the time rangerangeEndingTimeInMillis
- a long representing the ending time for the time range
-
DailyCalendar
public DailyCalendar(java.util.TimeZone timeZone, long rangeStartingTimeInMillis, long rangeEndingTimeInMillis)
Create aDailyCalendar
with a time range defined by the specified values and nobaseCalendar
. The values are subject to the following considerations:- Only the time-of-day portion of the specified values will be used
- The starting time must be before the ending time of the defined
time range. Note this means that a time range may not cross
daily boundaries (10PM - 2AM). (because only time value are
are used, it is possible for the two values to represent a valid
time range and
rangeStartingTime > rangeEndingTime
)
- Parameters:
timeZone
- the time zone for of theDailyCalendar
which will also be used to resolve the given start/end times.rangeStartingTimeInMillis
- a long representing the starting time for the time rangerangeEndingTimeInMillis
- a long representing the ending time for the time range
-
DailyCalendar
public DailyCalendar(Calendar baseCalendar, java.util.TimeZone timeZone, long rangeStartingTimeInMillis, long rangeEndingTimeInMillis)
Create aDailyCalendar
with a time range defined by the specified values and the specifiedbaseCalendar
. The values are subject to the following considerations:- Only the time-of-day portion of the specified values will be used
- The starting time must be before the ending time of the defined
time range. Note this means that a time range may not cross
daily boundaries (10PM - 2AM). (because only time value are
are used, it is possible for the two values to represent a valid
time range and
rangeStartingTime > rangeEndingTime
)
- Parameters:
baseCalendar
- the base calendar for this calendar instance – seeBaseCalendar
for more information on base calendar functionalitytimeZone
- the time zone for of theDailyCalendar
which will also be used to resolve the given start/end times.rangeStartingTimeInMillis
- a long representing the starting time for the time rangerangeEndingTimeInMillis
- a long representing the ending time for the time range
-
-
Method Detail
-
clone
public java.lang.Object clone()
- Specified by:
clone
in interfaceCalendar
- Overrides:
clone
in classBaseCalendar
-
isTimeIncluded
public boolean isTimeIncluded(long timeInMillis)
Determines whether the given time (in milliseconds) is 'included' by theBaseCalendar
- Specified by:
isTimeIncluded
in interfaceCalendar
- Overrides:
isTimeIncluded
in classBaseCalendar
- Parameters:
timeInMillis
- the date/time to test- Returns:
- a boolean indicating whether the specified time is 'included' by
the
BaseCalendar
- See Also:
Calendar.isTimeIncluded(long)
-
getNextIncludedTime
public long getNextIncludedTime(long timeInMillis)
Determines the next time included by theDailyCalendar
after the specified time.- Specified by:
getNextIncludedTime
in interfaceCalendar
- Overrides:
getNextIncludedTime
in classBaseCalendar
- Parameters:
timeInMillis
- the initial date/time after which to find an included time- Returns:
- the time in milliseconds representing the next time included after the specified time.
- See Also:
Calendar.getNextIncludedTime(long)
-
getTimeRangeStartingTimeInMillis
public long getTimeRangeStartingTimeInMillis(long timeInMillis)
Returns the start time of the time range (in milliseconds) of the day specified intimeInMillis
- Parameters:
timeInMillis
- a time containing the desired date for the starting time of the time range.- Returns:
- a date/time (in milliseconds) representing the start time of the time range for the specified date.
-
getTimeRangeEndingTimeInMillis
public long getTimeRangeEndingTimeInMillis(long timeInMillis)
Returns the end time of the time range (in milliseconds) of the day specified intimeInMillis
- Parameters:
timeInMillis
- a time containing the desired date for the ending time of the time range.- Returns:
- a date/time (in milliseconds) representing the end time of the time range for the specified date.
-
getInvertTimeRange
public boolean getInvertTimeRange()
Indicates whether the time range represents an inverted time range (see class description).- Returns:
- a boolean indicating whether the time range is inverted
-
setInvertTimeRange
public void setInvertTimeRange(boolean flag)
Indicates whether the time range represents an inverted time range (see class description).- Parameters:
flag
- the new value for theinvertTimeRange
flag.
-
toString
public java.lang.String toString()
Returns a string representing the properties of theDailyCalendar
- Overrides:
toString
in classjava.lang.Object
- Returns:
- the properteis of the DailyCalendar in a String format
-
setTimeRange
public void setTimeRange(java.lang.String rangeStartingTimeString, java.lang.String rangeEndingTimeString)
Sets the time range for theDailyCalendar
to the times represented in the specified Strings.- Parameters:
rangeStartingTimeString
- a String representing the start time of the time rangerangeEndingTimeString
- a String representing the end time of the excluded time range
-
setTimeRange
public void setTimeRange(int rangeStartingHourOfDay, int rangeStartingMinute, int rangeStartingSecond, int rangeStartingMillis, int rangeEndingHourOfDay, int rangeEndingMinute, int rangeEndingSecond, int rangeEndingMillis)
Sets the time range for theDailyCalendar
to the times represented in the specified values.- Parameters:
rangeStartingHourOfDay
- the hour of the start of the time rangerangeStartingMinute
- the minute of the start of the time rangerangeStartingSecond
- the second of the start of the time rangerangeStartingMillis
- the millisecond of the start of the time rangerangeEndingHourOfDay
- the hour of the end of the time rangerangeEndingMinute
- the minute of the end of the time rangerangeEndingSecond
- the second of the end of the time rangerangeEndingMillis
- the millisecond of the start of the time range
-
setTimeRange
public void setTimeRange(java.util.Calendar rangeStartingCalendar, java.util.Calendar rangeEndingCalendar)
Sets the time range for theDailyCalendar
to the times represented in the specifiedjava.util.Calendar
s.- Parameters:
rangeStartingCalendar
- a Calendar containing the start time for theDailyCalendar
rangeEndingCalendar
- a Calendar containing the end time for theDailyCalendar
-
setTimeRange
public void setTimeRange(long rangeStartingTime, long rangeEndingTime)
Sets the time range for theDailyCalendar
to the times represented in the specified values.- Parameters:
rangeStartingTime
- the starting time (in milliseconds) for the time rangerangeEndingTime
- the ending time (in milliseconds) for the time range
-
-