Class ScheduleComputeHelper

java.lang.Object
com.espertech.esper.common.internal.schedule.ScheduleComputeHelper

public final class ScheduleComputeHelper extends Object
For a crontab-like schedule, this class computes the next occurance given a start time and a specification of what the schedule looks like. The resolution at which this works is at the second level. The next occurance is always at least 1 second ahead. The class implements an algorithm that starts at the highest precision (seconds) and continues to the lowest precicion (month). For each precision level the algorithm looks at the list of valid values and finds a value for each that is equal to or greater then the valid values supplied. If no equal or greater value was supplied, it will reset all higher precision elements to its minimum value.
  • Constructor Details

    • ScheduleComputeHelper

      public ScheduleComputeHelper()
  • Method Details

    • computeNextOccurance

      public static long computeNextOccurance(ScheduleSpec spec, long afterTimeInMillis, TimeZone timeZone, TimeAbacus timeAbacus)
      Computes the next lowest date in milliseconds based on a specification and the from-time passed in.
      Parameters:
      spec - defines the schedule
      afterTimeInMillis - defines the start time
      timeZone - time zone
      timeAbacus - time abacus
      Returns:
      a long date millisecond value for the next schedule occurance matching the spec
    • computeDeltaNextOccurance

      public static long computeDeltaNextOccurance(ScheduleSpec spec, long afterTimeInMillis, TimeZone timeZone, TimeAbacus timeAbacus)
      Computes the next lowest date in milliseconds based on a specification and the from-time passed in and returns the delta from the current time.
      Parameters:
      spec - defines the schedule
      afterTimeInMillis - defines the start time
      timeZone - time zone
      timeAbacus - time abacus
      Returns:
      a long millisecond value representing the delta between current time and the next schedule occurance matching the spec