public class CronTrigger extends Object implements Trigger
Trigger
implementation for cron expressions. Wraps a
CronExpression
which parses according to common crontab conventions.
Supports a Quartz day-of-month/week field with an L/# expression. Follows common cron conventions in every other respect, including 0-6 for SUN-SAT (plus 7 for SUN as well). Note that Quartz deviates from the day-of-week convention in cron through 1-7 for SUN-SAT whereas Spring strictly follows cron even in combination with the optional Quartz-specific L/# expressions.
CronExpression
Constructor and Description |
---|
CronTrigger(String expression)
Build a
CronTrigger from the pattern provided in the default time zone. |
CronTrigger(String expression,
TimeZone timeZone)
Build a
CronTrigger from the pattern provided in the given time zone. |
CronTrigger(String expression,
ZoneId zoneId)
Build a
CronTrigger from the pattern provided in the given time zone. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other) |
String |
getExpression()
Return the cron pattern that this trigger has been built with.
|
int |
hashCode() |
Date |
nextExecutionTime(TriggerContext triggerContext)
Determine the next execution time according to the given trigger context.
|
String |
toString() |
public CronTrigger(String expression)
CronTrigger
from the pattern provided in the default time zone.expression
- a space-separated list of time fields, following cron
expression conventionspublic CronTrigger(String expression, TimeZone timeZone)
CronTrigger
from the pattern provided in the given time zone.expression
- a space-separated list of time fields, following cron
expression conventionstimeZone
- a time zone in which the trigger times will be generatedpublic CronTrigger(String expression, ZoneId zoneId)
CronTrigger
from the pattern provided in the given time zone.expression
- a space-separated list of time fields, following cron
expression conventionszoneId
- a time zone in which the trigger times will be generatedCronExpression.parse(String)
public String getExpression()
public Date nextExecutionTime(TriggerContext triggerContext)
Next execution times are calculated based on the completion time of the previous execution; therefore, overlapping executions won't occur.
nextExecutionTime
in interface Trigger
triggerContext
- context object encapsulating last execution times
and last completion timenull
if the trigger won't fire anymore