Interface ExecutionTime
- All Known Implementing Classes:
CompositeExecutionTime,SingleExecutionTime
public interface ExecutionTime
Calculates execution time given a cron pattern.
-
Method Summary
Modifier and TypeMethodDescriptiondefault intcountExecutions(ZonedDateTime startDate, ZonedDateTime endDate) Provide count of times cron expression would execute between given start and end datesstatic ExecutionTimeCreates execution time for given Cron.default List<ZonedDateTime> getExecutionDates(ZonedDateTime startDate, ZonedDateTime endDate) Provide date times when cron expression would execute between given start and end dates.booleanisMatch(ZonedDateTime date) Provide feedback if a given date matches the cron expression.lastExecution(ZonedDateTime date) Provide nearest date for last execution.nextExecution(ZonedDateTime date) Provide nearest date for next execution.Provide nearest time from last execution.Provide nearest time for next execution.
-
Method Details
-
forCron
Creates execution time for given Cron.- Parameters:
cron- - Cron instance- Returns:
- ExecutionTime instance
-
nextExecution
Provide nearest date for next execution.- Parameters:
date- - ZonedDateTime instance. If null, a NullPointerException will be raised.- Returns:
- Optional ZonedDateTime instance, never null. Contains next execution time or empty.
-
timeToNextExecution
Provide nearest time for next execution. Due to the question #468 we clarify: crons execute on local instance time. See: https://serverfault.com/questions/791713/what-time-zone-is-a-cron-job-using We ask for a ZonedDateTime for two reasons: (i) to provide flexibility on which timezone the cron is being executed (ii) to be able to reproduce issues regardless of our own local time (e.g.: daylight savings, etc.)- Parameters:
date- - ZonedDateTime instance. If null, a NullPointerException will be raised.- Returns:
- Duration instance, never null. Time to next execution.
-
lastExecution
Provide nearest date for last execution. Due to the question #468 we clarify: crons execute on local instance time. See: https://serverfault.com/questions/791713/what-time-zone-is-a-cron-job-using We ask for a ZonedDateTime for two reasons: (i) to provide flexibility on which timezone the cron is being executed (ii) to be able to reproduce issues regardless of our own local time (e.g.: daylight savings, etc.)- Parameters:
date- - ZonedDateTime instance. If null, a NullPointerException will be raised.- Returns:
- Optional ZonedDateTime instance, never null. Last execution time or empty.
-
timeFromLastExecution
Provide nearest time from last execution.- Parameters:
date- - ZonedDateTime instance. If null, a NullPointerException will be raised.- Returns:
- Duration instance, never null. Time from last execution.
-
isMatch
Provide feedback if a given date matches the cron expression.- Parameters:
date- - ZonedDateTime instance. If null, a NullPointerException will be raised.- Returns:
- true if date matches cron expression requirements, false otherwise.
-
countExecutions
Provide count of times cron expression would execute between given start and end dates- Parameters:
startDate- - Start date. If null, a NullPointerException will be raised.endDate- - End date. If null, a NullPointerException will be raised.- Returns:
- count of executions
-
getExecutionDates
Provide date times when cron expression would execute between given start and end dates. End date should be after start date. Otherwise, IllegalArgumentException is raised- Parameters:
startDate- - Start date. If null, a NullPointerException will be raised.endDate- - End date. If null, a NullPointerException will be raised.- Returns:
- list of date times
-