public class CronCalendar extends AbstractCalendar<CronCalendar>
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(CronCalendar aOther) |
CronCalendar(ICalendar baseCalendar,
String expression)
Create a
CronCalendar with the given cron expression and
baseCalendar. |
CronCalendar(ICalendar baseCalendar,
String expression,
TimeZone timeZone)
Create a
CronCalendar with the given cron exprssion,
baseCalendar, and TimeZone. |
CronCalendar(String expression)
Create a
CronCalendar with the given cron expression and no
baseCalendar. |
| Modifier and Type | Method and Description |
|---|---|
CronCalendar |
getClone() |
CronExpression |
getCronExpression()
Returns the object representation of the cron expression that defines the
dates and times this calendar excludes.
|
long |
getNextIncludedTime(long timeInMillis)
Determines the next time included by the
CronCalendar after
the specified time. |
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
AbstractCalendar |
void |
setCronExpression(CronExpression expression)
Sets the cron expression for the calendar to a new value
|
void |
setCronExpression(String expression)
Sets the cron expression for the calendar to a new value
|
void |
setTimeZone(TimeZone timeZone)
Sets the time zone for which the
CronExpression of this
CronCalendar will be resolved. |
String |
toString()
Returns a string representing the properties of the
CronCalendar |
createJavaCalendar, createJavaCalendar, getBaseCalendar, getDescription, getEndOfDayJavaCalendar, getStartOfDayJavaCalendar, setBaseCalendar, setDescriptionpublic CronCalendar(@Nonnull CronCalendar aOther)
public CronCalendar(String expression) throws ParseException
CronCalendar with the given cron expression and no
baseCalendar.expression - a String representation of the desired cron expressionParseExceptionpublic CronCalendar(ICalendar baseCalendar, String expression) throws ParseException
CronCalendar with the given cron expression and
baseCalendar.baseCalendar - the base calendar for this calendar instance – see
AbstractCalendar for more information on base calendar
functionalityexpression - a String representation of the desired cron expressionParseExceptionpublic CronCalendar(ICalendar baseCalendar, String expression, TimeZone timeZone) throws ParseException
CronCalendar with the given cron exprssion,
baseCalendar, and TimeZone.baseCalendar - the base calendar for this calendar instance – see
AbstractCalendar 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.ParseExceptionpublic TimeZone getTimeZone()
CronExpression of this
CronCalendar will be resolved.
Overrides to defer to
its AbstractCalendar.getTimeZone()CronExpression.
getTimeZone in class AbstractCalendar<CronCalendar>public void setTimeZone(TimeZone timeZone)
CronExpression of this
CronCalendar will be resolved. If timeZone is
null then TimeZone.getDefault() will be used.
Overrides to
defer to its AbstractCalendar.setTimeZone(TimeZone)CronExpression.
setTimeZone in class AbstractCalendar<CronCalendar>public boolean isTimeIncluded(long timeInMillis)
AbstractCalendarisTimeIncluded in interface ICalendarisTimeIncluded in class AbstractCalendar<CronCalendar>timeInMillis - the date/time to testCronCalendarICalendar.isTimeIncluded(long)public long getNextIncludedTime(long timeInMillis)
CronCalendar after
the specified time.getNextIncludedTime in interface ICalendargetNextIncludedTime in class AbstractCalendar<CronCalendar>timeInMillis - the initial date/time after which to find an included timeICalendar.getNextIncludedTime(long)public String toString()
CronCalendar@Nonnull public CronExpression getCronExpression()
CronExpressionpublic void setCronExpression(@Nonnull String expression) throws ParseException
expression - the new string value to build a cron expression fromParseException - if the string expression cannot be parsedpublic void setCronExpression(@Nonnull CronExpression expression)
expression - the new cron expression@Nonnull public CronCalendar getClone()
Copyright © 2016–2021 Philip Helger. All rights reserved.