Defines cron-like utility for scheduled times.
Scheduled Times
CronSchedule
determines its scheduled times using fields, where each field
is a sorted sequence of distinct values specifying a component of time.
The times
field specifies local times in schedule. It must include at least
one value.
The daysOfMonth
field specifies days of month in schedule. If empty, then
every day is implied unless daysOfWeek
is non-empty.
The months
field specifies months in schedule. If empty, then every month
is implied.
The daysOfWeek
field specifies days of week in schedule. If empty, then
every day is implied unless daysOfMonth
is non-empty.
If both daysOfMonth
and daysOfWeek
are non-empty, then scheduled times
are determined as a union of both fields.
import java.time.LocalTime.NOON
import java.time.Month.{ OCTOBER, NOVEMBER, DECEMBER }
import little.time.{ CronSchedule, TimeStringMethods }
// Create schedule
val schedule = CronSchedule(
times = Seq(NOON),
daysOfMonth = Seq(1, 15),
months = Seq(OCTOBER, NOVEMBER, DECEMBER))
val start = "2020-10-01".toLocalDate
val end = "2020-12-31".toLocalDate
// Iterate over scheduled times
schedule.between(start, end).foreach { time =>
println(s"${time.toLocalDate} at ${time.toLocalTime}")
}
// Create schedule using cron-like syntax
val altSchedule = CronSchedule("0 12 1,15 10-12 *")
- Companion:
- object
Value members
Abstract methods
Creates new cron schedule by replacing days of month.
Creates new cron schedule by replacing days of month.
- Value parameters:
- days
days of month
- Returns:
new cron schedule
Creates new cron schedule by replacing days of week.
Creates new cron schedule by replacing days of week.
- Value parameters:
- days
days of week
- Returns:
new cron schedule
Creates new cron schedule by replacing months.
Creates new cron schedule by replacing months.
- Value parameters:
- months
months
- Returns:
new cron schedule
Concrete methods
Creates new cron schedule by replacing days of month.
Creates new cron schedule by replacing days of month.
- Value parameters:
- more
additional days of month
- one
day of month
- Returns:
new cron schedule
Creates new cron schedule by replacing days of week.
Creates new cron schedule by replacing days of week.
- Value parameters:
- more
additional days of week
- one
day of week
- Returns:
new cron schedule
Creates new cron schedule by replacing months.
Creates new cron schedule by replacing months.
- Value parameters:
- more
additional months
- one
month
- Returns:
new cron schedule
Inherited methods
Creates new schedule by adding supplied scheduled time.
Creates new schedule by adding supplied scheduled time.
- Value parameters:
- time
schedule time
- Returns:
new schedule
- Note:
Alias to
add
- Inherited from:
- Schedule
Creates new schedule by combining supplied schedule.
Creates new schedule by combining supplied schedule.
- Value parameters:
- other
schedule
- Returns:
new schedule
- Note:
Alias to
combine
- Inherited from:
- Schedule
Creates new schedule by adding supplied scheduled time.
Creates new schedule by adding supplied scheduled time.
- Value parameters:
- time
schedule time
- Returns:
new schedule
- Inherited from:
- Schedule
Gets scheduled times in given period.
Gets scheduled times in given period.
Equivalent to: between(start.atTime(LocalTime.MIN), end.atTime(LocalTime.MAX))
- Value parameters:
- end
end of period
- start
start of period
- Note:
Both
start
andend
are inclusive.- Inherited from:
- Schedule
Gets scheduled times in given period.
Gets scheduled times in given period.
- Value parameters:
- end
end of period
- start
start of period
- Note:
Both
start
andend
are inclusive.- Inherited from:
- Schedule
Creates new schedule by combining supplied schedule.
Creates new schedule by combining supplied schedule.
- Value parameters:
- other
schedule
- Returns:
new schedule
- Inherited from:
- Schedule