Interface ExecutionTime
- All Known Implementing Classes:
CompositeExecutionTime,SingleExecutionTime
public interface ExecutionTime
Calculates execution time given a cron pattern.
-
Method Summary
Modifier and TypeMethodDescriptiondefault intcountExecutions(long startMillis, long endMillis) Provide count of times cron expression would execute between given start and end datesdefault intcountExecutions(long startMillis, long endMillis, ZoneId zoneId) Provide count of times cron expression would execute between given start and end datesdefault intcountExecutions(Instant startInstant, Instant endInstant) Provide count of times cron expression would execute between given start and end datesdefault intcountExecutions(Instant startInstant, Instant endInstant, ZoneId zoneId) Provide count of times cron expression would execute between given start and end datesdefault 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.getExecutionDates(long startMillis, long endMillis) Provide date times when cron expression would execute between given start and end dates.getExecutionDates(long startMillis, long endMillis, ZoneId zoneId) Provide date times when cron expression would execute between given start and end dates.getExecutionDates(Instant startInstant, Instant endInstant) Provide date times when cron expression would execute between given start and end dates.getExecutionDates(Instant startInstant, Instant endInstant, ZoneId zoneId) Provide date times when cron expression would execute between given start and end dates.default List<ZonedDateTime> getExecutionDates(ZonedDateTime startDate, ZonedDateTime endDate) Provide date times when cron expression would execute between given start and end dates.default booleanisMatch(long millis) Provide feedback if a given date matches the cron expression.default booleanProvide feedback if a given date matches the cron expression.default booleanProvide feedback if a given date matches the cron expression.default booleanProvide feedback if a given date matches the cron expression.booleanisMatch(ZonedDateTime date) Provide feedback if a given date matches the cron expression.default OptionalLonglastExecution(long millis) Provide nearest date for last execution.default OptionalLonglastExecution(long millis, ZoneId zoneId) Provide nearest date for last execution.lastExecution(Instant instant) Provide nearest date for last execution.lastExecution(Instant instant, ZoneId zoneId) Provide nearest date for last execution.lastExecution(ZonedDateTime date) Provide nearest date for last execution.default OptionalLongnextExecution(long millis) Provide nearest date for next execution.default OptionalLongnextExecution(long millis, ZoneId zoneId) Provide nearest date for next execution.nextExecution(Instant instant) Provide nearest date for next execution.nextExecution(Instant instant, ZoneId zoneId) Provide nearest date for next execution.nextExecution(ZonedDateTime date) Provide nearest date for next execution.timeFromLastExecution(long millis) Provide nearest time from last execution.timeFromLastExecution(long millis, ZoneId zoneId) Provide nearest time from last execution.timeFromLastExecution(Instant instant) Provide nearest time from last execution.timeFromLastExecution(Instant instant, ZoneId zoneId) Provide nearest time from last execution.Provide nearest time from last execution.timeToNextExecution(long millis) Provide nearest time for next execution.timeToNextExecution(long millis, ZoneId zoneId) Provide nearest time for next execution.timeToNextExecution(Instant instant) Provide nearest time for next execution.timeToNextExecution(Instant instant, ZoneId zoneId) Provide nearest time for next 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.
-
nextExecution
Provide nearest date for next execution.- Parameters:
instant- - Instant instance. If null, a NullPointerException will be raised.- Returns:
- Optional Instant instance, never null. Contains next execution time or empty.
-
nextExecution
Provide nearest date for next execution.- Parameters:
instant- - Instant instance. If null, a NullPointerException will be raised.zoneId- - ZoneId instance. If null, a NullPointerException will be raised.- Returns:
- Optional Instant instance, never null. Contains next execution time or empty.
-
nextExecution
Provide nearest date for next execution.- Parameters:
millis- - milliseconds in long.- Returns:
- OptionalLong instance, never null. Contains next execution time or empty.
-
nextExecution
Provide nearest date for next execution.- Parameters:
millis- - milliseconds in long.zoneId- - ZoneId instance. If null, a NullPointerException will be raised.- Returns:
- OptionalLong 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.
-
timeToNextExecution
Provide nearest time for next execution.- Parameters:
instant- - Instant instance. If null, a NullPointerException will be raised.- Returns:
- Duration instance, never null. Time to next execution.
-
timeToNextExecution
Provide nearest time for next execution.- Parameters:
instant- - Instant instance. If null, a NullPointerException will be raised.zoneId- - ZoneId instance. If null, a NullPointerException will be raised.- Returns:
- Duration instance, never null. Time to next execution.
-
timeToNextExecution
Provide nearest time for next execution.- Parameters:
millis- - milliseconds in long.- Returns:
- Duration instance, never null. Time to next execution.
-
timeToNextExecution
Provide nearest time for next execution.- Parameters:
millis- - milliseconds in long.zoneId- - ZoneId 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.
-
lastExecution
Provide nearest date for last execution.- Parameters:
instant- - Instant instance. If null, a NullPointerException will be raised.- Returns:
- Optional Instant instance, never null. Last execution time or empty.
-
lastExecution
Provide nearest date for last execution.- Parameters:
instant- - Instant instance. If null, a NullPointerException will be raised.zoneId- - ZoneId instance. If null, a NullPointerException will be raised.- Returns:
- Optional Instant instance, never null. Last execution time or empty.
-
lastExecution
Provide nearest date for last execution.- Parameters:
millis- - milliseconds in long.- Returns:
- OptionalLong instance, never null. Last execution time or empty.
-
lastExecution
Provide nearest date for last execution.- Parameters:
millis- - milliseconds in long.zoneId- - ZoneId instance. If null, a NullPointerException will be raised.- Returns:
- OptionalLong 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.
-
timeFromLastExecution
Provide nearest time from last execution.- Parameters:
instant- - Instant instance. If null, a NullPointerException will be raised.- Returns:
- Duration instance, never null. Time from last execution.
-
timeFromLastExecution
Provide nearest time from last execution.- Parameters:
instant- - Instant instance. If null, a NullPointerException will be raised.zoneId- - ZoneId instance. If null, a NullPointerException will be raised.- Returns:
- Duration instance, never null. Time from last execution.
-
timeFromLastExecution
Provide nearest time from last execution.- Parameters:
millis- - milliseconds in long.- Returns:
- Duration instance, never null. Time from last execution.
-
timeFromLastExecution
Provide nearest time from last execution.- Parameters:
millis- - milliseconds in long.zoneId- - ZoneId 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.
-
isMatch
Provide feedback if a given date matches the cron expression.- Parameters:
instant- - Instant instance. If null, a NullPointerException will be raised.- Returns:
- true if date matches cron expression requirements, false otherwise.
-
isMatch
Provide feedback if a given date matches the cron expression.- Parameters:
instant- - Instant instance. If null, a NullPointerException will be raised.zoneId- - ZoneId instance. If null, a NullPointerException will be raised.- Returns:
- true if date matches cron expression requirements, false otherwise.
-
isMatch
default boolean isMatch(long millis) Provide feedback if a given date matches the cron expression.- Parameters:
millis- - milliseconds in long.- Returns:
- true if date matches cron expression requirements, false otherwise.
-
isMatch
Provide feedback if a given date matches the cron expression.- Parameters:
millis- - milliseconds in long.zoneId- - ZoneId 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
-
countExecutions
Provide count of times cron expression would execute between given start and end dates- Parameters:
startInstant- - Start date. If null, a NullPointerException will be raised.endInstant- - End date. If null, a NullPointerException will be raised.- Returns:
- count of executions
-
countExecutions
Provide count of times cron expression would execute between given start and end dates- Parameters:
startInstant- - Start date. If null, a NullPointerException will be raised.endInstant- - End date. If null, a NullPointerException will be raised.zoneId- - ZoneId instance. If null, a NullPointerException will be raised.- Returns:
- count of executions
-
countExecutions
default int countExecutions(long startMillis, long endMillis) Provide count of times cron expression would execute between given start and end dates- Parameters:
startMillis- - Start date in milliseconds.endMillis- - End date in milliseconds.- Returns:
- count of executions
-
countExecutions
Provide count of times cron expression would execute between given start and end dates- Parameters:
startMillis- - Start date in milliseconds.endMillis- - End date in milliseconds.zoneId- - ZoneId instance. 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
-
getExecutionDates
Provide date times when cron expression would execute between given start and end dates.- Parameters:
startInstant- - Start date. If null, a NullPointerException will be raised.endInstant- - End date. If null, a NullPointerException will be raised.- Returns:
- list of Instants
-
getExecutionDates
Provide date times when cron expression would execute between given start and end dates.- Parameters:
startInstant- - Start date. If null, a NullPointerException will be raised.endInstant- - End date. If null, a NullPointerException will be raised.zoneId- - ZoneId instance. If null, a NullPointerException will be raised.- Returns:
- list of Instants
-
getExecutionDates
Provide date times when cron expression would execute between given start and end dates.- Parameters:
startMillis- - Start date in milliseconds.endMillis- - End date in milliseconds.- Returns:
- list of millisecond timestamps in Long
-
getExecutionDates
Provide date times when cron expression would execute between given start and end dates.- Parameters:
startMillis- - Start date in milliseconds.endMillis- - End date in milliseconds.zoneId- - ZoneId instance. If null, a NullPointerException will be raised.- Returns:
- list of millisecond timestamps in Long
-