Class CronSchedule

java.lang.Object
org.sterl.spring.persistent_tasks.api.CronSchedule
All Implemented Interfaces:
Serializable, Schedule

public final class CronSchedule extends Object implements Schedule
A schedule based on a cron expression. Always uses UTC timezone.

Examples:

  • "0 0 2 * * *" - Every day at 2:00 AM UTC
  • "0 0 * * * *" - Every hour on the hour
  • "0 */15 * * * *" - Every 15 minutes
See Also:
  • Constructor Details

    • CronSchedule

      public CronSchedule(String expression)
      Creates a new cron schedule.
      Parameters:
      expression - the cron expression (6 fields: second minute hour day month weekday)
      Throws:
      IllegalArgumentException - if the cron expression is invalid
  • Method Details

    • next

      public OffsetDateTime next(OffsetDateTime from)
      Description copied from interface: Schedule
      Calculates the next execution time from the given time.
      Specified by:
      next in interface Schedule
      Parameters:
      from - the reference time to calculate from
      Returns:
      the next execution time after the given time
    • description

      public String description()
      Description copied from interface: Schedule
      Returns a human-readable description of this schedule.
      Specified by:
      description in interface Schedule
      Returns:
      description of the schedule