Class CompositeExecutionTime

java.lang.Object
io.github.projectunified.cronutils.model.time.CompositeExecutionTime
All Implemented Interfaces:
ExecutionTime

public class CompositeExecutionTime extends Object implements ExecutionTime
  • Constructor Details

    • CompositeExecutionTime

      public CompositeExecutionTime(List<ExecutionTime> executionTimes)
  • Method Details

    • nextExecution

      public Optional<ZonedDateTime> nextExecution(ZonedDateTime date)
      Description copied from interface: ExecutionTime
      Provide nearest date for next execution.
      Specified by:
      nextExecution in interface ExecutionTime
      Parameters:
      date - - ZonedDateTime instance. If null, a NullPointerException will be raised.
      Returns:
      Optional ZonedDateTime instance, never null. Contains next execution time or empty.
    • timeToNextExecution

      public Optional<Duration> timeToNextExecution(ZonedDateTime date)
      Description copied from interface: ExecutionTime
      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.)
      Specified by:
      timeToNextExecution in interface ExecutionTime
      Parameters:
      date - - ZonedDateTime instance. If null, a NullPointerException will be raised.
      Returns:
      Duration instance, never null. Time to next execution.
    • lastExecution

      public Optional<ZonedDateTime> lastExecution(ZonedDateTime date)
      Description copied from interface: ExecutionTime
      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.)
      Specified by:
      lastExecution in interface ExecutionTime
      Parameters:
      date - - ZonedDateTime instance. If null, a NullPointerException will be raised.
      Returns:
      Optional ZonedDateTime instance, never null. Last execution time or empty.
    • timeFromLastExecution

      public Optional<Duration> timeFromLastExecution(ZonedDateTime date)
      Description copied from interface: ExecutionTime
      Provide nearest time from last execution.
      Specified by:
      timeFromLastExecution in interface ExecutionTime
      Parameters:
      date - - ZonedDateTime instance. If null, a NullPointerException will be raised.
      Returns:
      Duration instance, never null. Time from last execution.
    • isMatch

      public boolean isMatch(ZonedDateTime date)
      Description copied from interface: ExecutionTime
      Provide feedback if a given date matches the cron expression.
      Specified by:
      isMatch in interface ExecutionTime
      Parameters:
      date - - ZonedDateTime instance. If null, a NullPointerException will be raised.
      Returns:
      true if date matches cron expression requirements, false otherwise.