Class CronTrigger
- java.lang.Object
- org.springframework.scheduling.support.CronTrigger
- All Implemented Interfaces:
Trigger
public class CronTrigger extends Object implements Trigger
Trigger
implementation for cron expressions. Wraps aCronSequenceGenerator
.- Since:
- 3.0
- Author:
- Juergen Hoeller
- See Also:
CronSequenceGenerator
Constructor Summary
Constructors Constructor Description CronTrigger(String expression)
Build aCronTrigger
from the pattern provided in the default time zone.CronTrigger(String expression, TimeZone timeZone)
Build aCronTrigger
from the pattern provided in the given time zone.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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()
Constructor Detail
CronTrigger
public CronTrigger(String expression)
Build aCronTrigger
from the pattern provided in the default time zone.- Parameters:
expression
- a space-separated list of time fields, following cron expression conventions
CronTrigger
public CronTrigger(String expression, TimeZone timeZone)
Build aCronTrigger
from the pattern provided in the given time zone.- Parameters:
expression
- a space-separated list of time fields, following cron expression conventionstimeZone
- a time zone in which the trigger times will be generated
Method Detail
getExpression
public String getExpression()
Return the cron pattern that this trigger has been built with.
nextExecutionTime
public Date nextExecutionTime(TriggerContext triggerContext)
Determine the next execution time according to the given trigger context.Next execution times are calculated based on the completion time of the previous execution; therefore, overlapping executions won't occur.
- Specified by:
nextExecutionTime
in interfaceTrigger
- Parameters:
triggerContext
- context object encapsulating last execution times and last completion time- Returns:
- the next execution time as defined by the trigger, or
null
if the trigger won't fire anymore