org.quartz.impl.calendar
Class DailyCalendar

java.lang.Object
  extended by org.quartz.impl.calendar.BaseCalendar
      extended by org.quartz.impl.calendar.DailyCalendar
All Implemented Interfaces:
Serializable, 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. Each DailyCalendar 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 property invertTimeRange is false (default), the time range defines a range of times in which triggers are not allowed to fire. If invertTimeRange is true, 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

Field Summary
 
Fields inherited from interface org.quartz.Calendar
MONTH
 
Constructor Summary
DailyCalendar(Calendar rangeStartingCalendar, Calendar rangeEndingCalendar)
          Create a DailyCalendar with a time range defined by the specified java.util.Calendars and no baseCalendar.
DailyCalendar(Calendar baseCalendar, Calendar rangeStartingCalendar, Calendar rangeEndingCalendar)
          Create a DailyCalendar with a time range defined by the specified java.util.Calendars and the specified baseCalendar.
DailyCalendar(Calendar baseCalendar, int rangeStartingHourOfDay, int rangeStartingMinute, int rangeStartingSecond, int rangeStartingMillis, int rangeEndingHourOfDay, int rangeEndingMinute, int rangeEndingSecond, int rangeEndingMillis)
          Create a DailyCalendar with a time range defined by the specified values and the specified baseCalendar.
DailyCalendar(Calendar baseCalendar, long rangeStartingTimeInMillis, long rangeEndingTimeInMillis)
          Create a DailyCalendar with a time range defined by the specified values and the specified baseCalendar.
DailyCalendar(Calendar baseCalendar, String rangeStartingTime, String rangeEndingTime)
          Create a DailyCalendar with a time range defined by the specified strings and the specified baseCalendar.
DailyCalendar(Calendar baseCalendar, TimeZone timeZone, long rangeStartingTimeInMillis, long rangeEndingTimeInMillis)
          Create a DailyCalendar with a time range defined by the specified values and the specified baseCalendar.
DailyCalendar(int rangeStartingHourOfDay, int rangeStartingMinute, int rangeStartingSecond, int rangeStartingMillis, int rangeEndingHourOfDay, int rangeEndingMinute, int rangeEndingSecond, int rangeEndingMillis)
          Create a DailyCalendar with a time range defined by the specified values and no baseCalendar.
DailyCalendar(long rangeStartingTimeInMillis, long rangeEndingTimeInMillis)
          Create a DailyCalendar with a time range defined by the specified values and no baseCalendar.
DailyCalendar(String rangeStartingTime, String rangeEndingTime)
          Create a DailyCalendar with a time range defined by the specified strings and no baseCalendar.
DailyCalendar(TimeZone timeZone, long rangeStartingTimeInMillis, long rangeEndingTimeInMillis)
          Create a DailyCalendar with a time range defined by the specified values and no baseCalendar.
 
Method Summary
 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 the DailyCalendar after the specified time.
 long getTimeRangeEndingTimeInMillis(long timeInMillis)
          Returns the end time of the time range (in milliseconds) of the day specified in timeInMillis
 long getTimeRangeStartingTimeInMillis(long timeInMillis)
          Returns the start time of the time range (in milliseconds) of the day specified in timeInMillis
 boolean isTimeIncluded(long timeInMillis)
          Determines whether the given time (in milliseconds) is 'included' by the BaseCalendar
 void setInvertTimeRange(boolean flag)
          Indicates whether the time range represents an inverted time range (see class description).
 void setTimeRange(Calendar rangeStartingCalendar, Calendar rangeEndingCalendar)
          Sets the time range for the DailyCalendar to the times represented in the specified java.util.Calendars.
 void setTimeRange(int rangeStartingHourOfDay, int rangeStartingMinute, int rangeStartingSecond, int rangeStartingMillis, int rangeEndingHourOfDay, int rangeEndingMinute, int rangeEndingSecond, int rangeEndingMillis)
          Sets the time range for the DailyCalendar to the times represented in the specified values.
 void setTimeRange(long rangeStartingTime, long rangeEndingTime)
          Sets the time range for the DailyCalendar to the times represented in the specified values.
 void setTimeRange(String rangeStartingTimeString, String rangeEndingTimeString)
          Sets the time range for the DailyCalendar to the times represented in the specified Strings.
 String toString()
          Returns a string representing the properties of the DailyCalendar
 
Methods inherited from class org.quartz.impl.calendar.BaseCalendar
createJavaCalendar, createJavaCalendar, getBaseCalendar, getDescription, getEndOfDayJavaCalendar, getStartOfDayJavaCalendar, getTimeZone, setBaseCalendar, setDescription, setTimeZone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DailyCalendar

public DailyCalendar(String rangeStartingTime,
                     String rangeEndingTime)
Create a DailyCalendar with a time range defined by the specified strings and no baseCalendar. rangeStartingTime and rangeEndingTime must be in the format "HH:MM[:SS[:mmm]]" where:

Note: This DailyCalendar will use the TimeZone.getDefault() time zone unless an explicit time zone is set via BaseCalendar.setTimeZone(TimeZone)

Parameters:
rangeStartingTime - a String representing the starting time for the time range
rangeEndingTime - a String representing the ending time for the the time range

DailyCalendar

public DailyCalendar(Calendar baseCalendar,
                     String rangeStartingTime,
                     String rangeEndingTime)
Create a DailyCalendar with a time range defined by the specified strings and the specified baseCalendar. rangeStartingTime and rangeEndingTime must be in the format "HH:MM[:SS[:mmm]]" where:

Note: This DailyCalendar will use the TimeZone.getDefault() time zone unless an explicit time zone is set via BaseCalendar.setTimeZone(TimeZone)

Parameters:
baseCalendar - the base calendar for this calendar instance – see BaseCalendar for more information on base calendar functionality
rangeStartingTime - a String representing the starting time for the time range
rangeEndingTime - 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 a DailyCalendar with a time range defined by the specified values and no baseCalendar. Values are subject to the following validations:

Note: This DailyCalendar will use the TimeZone.getDefault() time zone unless an explicit time zone is set via BaseCalendar.setTimeZone(TimeZone)

Parameters:
rangeStartingHourOfDay - the hour of the start of the time range
rangeStartingMinute - the minute of the start of the time range
rangeStartingSecond - the second of the start of the time range
rangeStartingMillis - the millisecond of the start of the time range
rangeEndingHourOfDay - the hour of the end of the time range
rangeEndingMinute - the minute of the end of the time range
rangeEndingSecond - the second of the end of the time range
rangeEndingMillis - 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 a DailyCalendar with a time range defined by the specified values and the specified baseCalendar. Values are subject to the following validations:

Note: This DailyCalendar will use the TimeZone.getDefault() time zone unless an explicit time zone is set via BaseCalendar.setTimeZone(TimeZone)

Parameters:
baseCalendar - the base calendar for this calendar instance – see BaseCalendar for more information on base calendar functionality
rangeStartingHourOfDay - the hour of the start of the time range
rangeStartingMinute - the minute of the start of the time range
rangeStartingSecond - the second of the start of the time range
rangeStartingMillis - the millisecond of the start of the time range
rangeEndingHourOfDay - the hour of the end of the time range
rangeEndingMinute - the minute of the end of the time range
rangeEndingSecond - the second of the end of the time range
rangeEndingMillis - the millisecond of the start of the time range

DailyCalendar

public DailyCalendar(Calendar rangeStartingCalendar,
                     Calendar rangeEndingCalendar)
Create a DailyCalendar with a time range defined by the specified java.util.Calendars and no baseCalendar. The Calendars are subject to the following considerations:

Note: This DailyCalendar will use the TimeZone.getDefault() time zone unless an explicit time zone is set via BaseCalendar.setTimeZone(TimeZone)

Parameters:
rangeStartingCalendar - a java.util.Calendar representing the starting time for the time range
rangeEndingCalendar - a java.util.Calendar representing the ending time for the time range

DailyCalendar

public DailyCalendar(Calendar baseCalendar,
                     Calendar rangeStartingCalendar,
                     Calendar rangeEndingCalendar)
Create a DailyCalendar with a time range defined by the specified java.util.Calendars and the specified baseCalendar. The Calendars are subject to the following considerations:

Note: This DailyCalendar will use the TimeZone.getDefault() time zone unless an explicit time zone is set via BaseCalendar.setTimeZone(TimeZone)

Parameters:
baseCalendar - the base calendar for this calendar instance – see BaseCalendar for more information on base calendar functionality
rangeStartingCalendar - a java.util.Calendar representing the starting time for the time range
rangeEndingCalendar - a java.util.Calendar representing the ending time for the time range

DailyCalendar

public DailyCalendar(long rangeStartingTimeInMillis,
                     long rangeEndingTimeInMillis)
Create a DailyCalendar with a time range defined by the specified values and no baseCalendar. The values are subject to the following considerations:

Note: This DailyCalendar will use the TimeZone.getDefault() time zone unless an explicit time zone is set via BaseCalendar.setTimeZone(TimeZone). You should use DailyCalendar(org.quartz.Calendar, java.util.TimeZone, long, long) if you don't want the given rangeStartingTimeInMillis and rangeEndingTimeInMillis to be evaluated in the default time zone.

Parameters:
rangeStartingTimeInMillis - a long representing the starting time for the time range
rangeEndingTimeInMillis - a long representing the ending time for the time range

DailyCalendar

public DailyCalendar(Calendar baseCalendar,
                     long rangeStartingTimeInMillis,
                     long rangeEndingTimeInMillis)
Create a DailyCalendar with a time range defined by the specified values and the specified baseCalendar. The values are subject to the following considerations:

Note: This DailyCalendar will use the TimeZone.getDefault() time zone unless an explicit time zone is set via BaseCalendar.setTimeZone(TimeZone). You should use DailyCalendar(org.quartz.Calendar, java.util.TimeZone, long, long) if you don't want the given rangeStartingTimeInMillis and rangeEndingTimeInMillis to be evaluated in the default time zone.

Parameters:
baseCalendar - the base calendar for this calendar instance – see BaseCalendar for more information on base calendar functionality
rangeStartingTimeInMillis - a long representing the starting time for the time range
rangeEndingTimeInMillis - a long representing the ending time for the time range

DailyCalendar

public DailyCalendar(TimeZone timeZone,
                     long rangeStartingTimeInMillis,
                     long rangeEndingTimeInMillis)
Create a DailyCalendar with a time range defined by the specified values and no baseCalendar. The values are subject to the following considerations:

Parameters:
timeZone - the time zone for of the DailyCalendar which will also be used to resolve the given start/end times.
rangeStartingTimeInMillis - a long representing the starting time for the time range
rangeEndingTimeInMillis - a long representing the ending time for the time range

DailyCalendar

public DailyCalendar(Calendar baseCalendar,
                     TimeZone timeZone,
                     long rangeStartingTimeInMillis,
                     long rangeEndingTimeInMillis)
Create a DailyCalendar with a time range defined by the specified values and the specified baseCalendar. The values are subject to the following considerations:

Parameters:
baseCalendar - the base calendar for this calendar instance – see BaseCalendar for more information on base calendar functionality
timeZone - the time zone for of the DailyCalendar which will also be used to resolve the given start/end times.
rangeStartingTimeInMillis - a long representing the starting time for the time range
rangeEndingTimeInMillis - a long representing the ending time for the time range
Method Detail

clone

public Object clone()
Specified by:
clone in interface Calendar
Overrides:
clone in class BaseCalendar

isTimeIncluded

public boolean isTimeIncluded(long timeInMillis)
Determines whether the given time (in milliseconds) is 'included' by the BaseCalendar

Specified by:
isTimeIncluded in interface Calendar
Overrides:
isTimeIncluded in class BaseCalendar
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 the DailyCalendar after the specified time.

Specified by:
getNextIncludedTime in interface Calendar
Overrides:
getNextIncludedTime in class BaseCalendar
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 in timeInMillis

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 in timeInMillis

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 the invertTimeRange flag.

toString

public String toString()
Returns a string representing the properties of the DailyCalendar

Overrides:
toString in class Object
Returns:
the properteis of the DailyCalendar in a String format

setTimeRange

public void setTimeRange(String rangeStartingTimeString,
                         String rangeEndingTimeString)
Sets the time range for the DailyCalendar to the times represented in the specified Strings.

Parameters:
rangeStartingTimeString - a String representing the start time of the time range
rangeEndingTimeString - 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 the DailyCalendar to the times represented in the specified values.

Parameters:
rangeStartingHourOfDay - the hour of the start of the time range
rangeStartingMinute - the minute of the start of the time range
rangeStartingSecond - the second of the start of the time range
rangeStartingMillis - the millisecond of the start of the time range
rangeEndingHourOfDay - the hour of the end of the time range
rangeEndingMinute - the minute of the end of the time range
rangeEndingSecond - the second of the end of the time range
rangeEndingMillis - the millisecond of the start of the time range

setTimeRange

public void setTimeRange(Calendar rangeStartingCalendar,
                         Calendar rangeEndingCalendar)
Sets the time range for the DailyCalendar to the times represented in the specified java.util.Calendars.

Parameters:
rangeStartingCalendar - a Calendar containing the start time for the DailyCalendar
rangeEndingCalendar - a Calendar containing the end time for the DailyCalendar

setTimeRange

public void setTimeRange(long rangeStartingTime,
                         long rangeEndingTime)
Sets the time range for the DailyCalendar to the times represented in the specified values.

Parameters:
rangeStartingTime - the starting time (in milliseconds) for the time range
rangeEndingTime - the ending time (in milliseconds) for the time range


Copyright 2001-2015, Terracotta, Inc.