Cron expression parsing, scheduling, and human-readable descriptions
implementation com.philiprehberger:cron-kitCron expression parsing, scheduling, and human-readable descriptions.
implementation("com.philiprehberger:cron-kit:0.2.0")
<dependency>
<groupId>com.philiprehberger</groupId>
<artifactId>cron-kit</artifactId>
<version>0.2.0</version>
</dependency>
import com.philiprehberger.cronkit.*
val cron = Cron.parse("*/15 9-17 * * MON-FRI")
cron.nextAfter(Instant.now())
cron.matches(Instant.now())
cron.describe() // "Every 15 minutes"
cron.between(start, end) // count occurrences in range
Cron.isValid("0 25 * * *") // false
| Function / Class | Description |
|---|---|
Cron.parse(expression) | Parse a 5-field cron expression |
Cron.isValid(expression) | Check if expression is valid |
CronExpression.nextAfter(instant) | Next matching time |
CronExpression.nextN(instant, count) | Next N matching times |
CronExpression.previousBefore(instant) | Previous matching time |
CronExpression.matches(instant) | Check if instant matches |
CronExpression.between(start, end) | Count occurrences in a time range |
CronExpression.describe() | Human-readable description |
./gradlew test
./gradlew build
If you find this project useful: