Class Cron

java.lang.Object
dev.relism.flash.ext.scheduler.Cron

public final class Cron extends Object
A cron expression compiled to bitmasks.

Accepts five fields (min hour dom mon dow) or six with a leading seconds field. Each is parsed once into a bitmask — a long for seconds and minutes, an int for the rest — so matching a candidate instant is a shift and a mask rather than a parse, a list walk or a set lookup.


 Cron.parse("0 0 3 * * *")    // 03:00:00 every day
 Cron.parse("*/15 * * * *")     // every 15 minutes
 Cron.parse("0 9 * * MON-FRI")  // 09:00 on weekdays
 
  • Method Details

    • parse

      public static Cron parse(String expression)
      Throws:
      IllegalArgumentException - if the expression is malformed — at boot, not at fire time
    • nextAfter

      public ZonedDateTime nextAfter(ZonedDateTime from)
      The first instant strictly after from that matches.

      Advances by the largest unit that cannot match rather than ticking second by second, so a yearly expression resolves in a few dozen iterations instead of thirty million.

    • toString

      public String toString()
      Overrides:
      toString in class Object