A Scala library for parsing and evaluating cron expressions.
- JDK 17 or later (compiled with
--release 17) - Scala 2.13.18 / 3.3.7 (cross-build supported)
Add the following to your build.sbt:
libraryDependencies += "com.github.j5ik2o" %% "chronos-parser-scala" % "<version>"import com.github.j5ik2o.cron.CronSchedule
import java.time.{Instant, ZoneId}
val cronSchedule = CronSchedule("*/3 * * * *", ZoneId.systemDefault())
val upcoming = cronSchedule.upcoming(Instant.now()).take(5)
upcoming.foreach(println)CronSchedule(expr, zoneId)- Create a schedule from a cron expressionschedule.upcoming(start)- Get a lazy list of upcoming instants matching the cron expressionschedule.getInstantAfter(base, minutes)- Get the next matching instant within a given number of minutesCronParser.parse(expr)- Parse a cron expression into an AST
| Field | Values | Special Characters |
|---|---|---|
| Minute | 0-59 | * , - / |
| Hour | 0-23 | * , - / |
| Day of Month | 1-31 | * , - / L |
| Month | 1-12 | * , - / |
| Day of Week | 0-7 (SUN-SAT) | * , - / |
MIT License (see LICENSE)