public class CronCalendar extends BaseCalendar
CronExpression. For example, you
could use this calendar to exclude all but business hours (8AM - 5PM) every
day using the expression "* * 0-7,18-23 ? * *".
It is important to remember that the cron expression here describes a set of
times to be excluded from firing. Whereas the cron expression in
CronTrigger describes a set of times that can
be included for firing. Thus, if a CronTrigger has a
given cron expression and is associated with a CronCalendar with
the same expression, the calendar will exclude all the times the
trigger includes, and they will cancel each other out.
| Constructor and Description |
|---|
CronCalendar(Calendar baseCalendar,
java.lang.String expression)
Create a
CronCalendar with the given cron expression and
baseCalendar. |
CronCalendar(Calendar baseCalendar,
java.lang.String expression,
java.util.TimeZone timeZone)
Create a
CronCalendar with the given cron exprssion,
baseCalendar, and TimeZone. |
CronCalendar(java.lang.String expression)
Create a
CronCalendar with the given cron expression and no
baseCalendar. |
CronCalendar(java.lang.String name,
Calendar baseCalendar,
java.lang.String expression)
Deprecated.
The use of
name is no longer supported. |
CronCalendar(java.lang.String name,
Calendar baseCalendar,
java.lang.String expression,
java.util.TimeZone timeZone)
Deprecated.
The use of
name is no longer supported. |
CronCalendar(java.lang.String name,
java.lang.String expression)
Deprecated.
The use of
name is no longer supported. |
| Modifier and Type | Method and Description |
|---|---|
CronExpression |
getCronExpression()
Returns the object representation of the cron expression that defines the
dates and times this calendar excludes.
|
java.lang.String |
getName()
Deprecated.
The use of
name is no longer supported. |
long |
getNextIncludedTime(long timeInMillis)
Determines the next time included by the
CronCalendar
after the specified time. |
java.util.TimeZone |
getTimeZone()
Returns the time zone for which the
CronExpression of
this CronCalendar will be resolved. |
boolean |
isTimeIncluded(long timeInMillis)
Determines whether the given time (in milliseconds) is 'included' by the
BaseCalendar |
void |
setCronExpression(CronExpression expression)
Sets the cron expression for the calendar to a new value
|
void |
setCronExpression(java.lang.String expression)
Sets the cron expression for the calendar to a new value
|
void |
setTimeZone(java.util.TimeZone timeZone)
Sets the time zone for which the
CronExpression of this
CronCalendar will be resolved. |
java.lang.String |
toString()
Returns a string representing the properties of the
CronCalendar |
buildHoliday, buildHoliday, getBaseCalendar, getDescription, getJavaCalendar, setBaseCalendar, setDescriptionpublic CronCalendar(java.lang.String expression)
throws java.text.ParseException
CronCalendar with the given cron expression and no
baseCalendar.expression - a String representation of the desired cron expressionjava.text.ParseExceptionpublic CronCalendar(Calendar baseCalendar, java.lang.String expression) throws java.text.ParseException
CronCalendar with the given cron expression and
baseCalendar.baseCalendar - the base calendar for this calendar instance –
see BaseCalendar for more information on base
calendar functionalityexpression - a String representation of the desired cron expressionjava.text.ParseExceptionpublic CronCalendar(Calendar baseCalendar, java.lang.String expression, java.util.TimeZone timeZone) throws java.text.ParseException
CronCalendar with the given cron exprssion,
baseCalendar, and TimeZone.baseCalendar - the base calendar for this calendar instance –
see BaseCalendar for more information on base
calendar functionalityexpression - a String representation of the desired cron expressiontimeZone - Specifies for which time zone the expression
should be interpreted, i.e. the expression 0 0 10 * * ?, is
resolved to 10:00 am in this time zone. If
timeZone is null then
TimeZone.getDefault() will be used.java.text.ParseExceptionpublic CronCalendar(java.lang.String name,
java.lang.String expression)
throws java.text.ParseException
name is no longer supported.java.text.ParseExceptionCronCalendar(String)public CronCalendar(java.lang.String name,
Calendar baseCalendar,
java.lang.String expression)
throws java.text.ParseException
name is no longer supported.java.text.ParseExceptionCronCalendar(Calendar, String)public CronCalendar(java.lang.String name,
Calendar baseCalendar,
java.lang.String expression,
java.util.TimeZone timeZone)
throws java.text.ParseException
name is no longer supported.java.text.ParseExceptionCronCalendar(Calendar, String, TimeZone)public java.util.TimeZone getTimeZone()
CronExpression of
this CronCalendar will be resolved.
Overrides to
defer to its BaseCalendar.getTimeZone()CronExpression.
getTimeZone in class BaseCalendarnull if Calendar should
use the TimeZone.getDefault()public void setTimeZone(java.util.TimeZone timeZone)
CronExpression of this
CronCalendar will be resolved. If timeZone
is null then TimeZone.getDefault() will be
used.
Overrides to
defer to its BaseCalendar.setTimeZone(TimeZone)CronExpression.
setTimeZone in class BaseCalendartimeZone - The time zone to use for this Calendar, null
if TimeZone.getDefault() should be usedpublic java.lang.String getName()
name is no longer supported.CronCalendarCronCalendarpublic boolean isTimeIncluded(long timeInMillis)
BaseCalendarisTimeIncluded in interface CalendarisTimeIncluded in class BaseCalendartimeInMillis - the date/time to testCronCalendarCalendar.isTimeIncluded(long)public long getNextIncludedTime(long timeInMillis)
CronCalendar
after the specified time.getNextIncludedTime in interface CalendargetNextIncludedTime in class BaseCalendartimeInMillis - the initial date/time after which to find an
included timeCalendar.getNextIncludedTime(long)public java.lang.String toString()
CronCalendartoString in class java.lang.Objectpublic CronExpression getCronExpression()
CronExpressionpublic void setCronExpression(java.lang.String expression)
throws java.text.ParseException
expression - the new string value to build a cron expression fromjava.text.ParseException - if the string expression cannot be parsedpublic void setCronExpression(CronExpression expression)
expression - the new cron expression