CronSchedule

Provides CronSchedule factory.

Companion:
class
trait Sum
trait Mirror
class Object
trait Matchable
class Any

Type members

Inherited types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Inherited from:
Mirror

Value members

Concrete methods

def apply(times: Seq[LocalTime], daysOfMonth: Seq[Int], months: Seq[Month], daysOfWeek: Seq[DayOfWeek]): CronSchedule

Creates cron schedule with supplied fields.

Creates cron schedule with supplied fields.

Examples

import java.time.DayOfWeek.SUNDAY
import java.time.Month.{ OCTOBER, NOVEMBER, DECEMBER }

import little.time.{ CronSchedule, TimeStringMethods }

// At noon on 1st and 15th in October thru December
val monthly = CronSchedule(
 times       = Seq("12:00".toLocalTime),
 daysOfMonth = Seq(1, 15),
 months      = Seq(OCTOBER, NOVEMBER, DECEMBER))

// At 8 AM every Sunday
val weekly = CronSchedule(
 times      = Seq("08:00".toLocalTime),
 daysOfWeek = Seq(SUNDAY)
)

// At 6 AM and 5 PM every day.
val daily = CronSchedule(
 times = Seq("06:00".toLocalTime, "17:00".toLocalTime)
)
Value parameters:
daysOfMonth

days of months

daysOfWeek

days of week

months

months

times

times

Note:

If times is empty, it is converted to Seq(LocalTime.MIDNIGHT).

def apply(fields: String): CronSchedule

Parses fields to cron schedule.

Parses fields to cron schedule.

Cron Schedule Format

The formatted cron schedule must be supplied as either 5 or 6 fields separated by space. If only 5 fields are supplied, then second defaults to 0.

FieldAllowed Values
second0-59
minute0-59
hour0-23
dayOfMonth1-31
month1-12
dayOfWeek0-7 (0 or 7 is Sunday)

A field may be specified as an asterisk (*), which denotes first-last based on field's allowed values.

A field may be specified as a list, where each value is separated by comma (,). For example, 10,11,12 in month.

A field may be specified as an inclusive range, where the range endpoints are separated by hyphen (-). For example, 5-7 in dayOfWeek.

A step may be appended to a range to include only incremental values, where range and step are supplied as range/step. For example, 0-30/5 in minute indicates every 5 minutes from 0 to 30, which alternatively could be specified as 0,5,10,15,20,25,30.

A step may also be appended to an asterisk to apply similar semantics. For example, */15 in minute indicates every 15 minutes.

Names may be supplied for month and dayOfWeek either as full names (e.g., Sunday and January) or their first 3 letters (e.g., Sun and Jan). Names are case-insensitive and are not permitted in ranges.

Examples

// At 8 AM every Sunday
val weekly = CronSchedule("0 8 * * Sun")

// At noon every day in October thru December
val daily = CronSchedule("0 12 * 10-12 *")

// Every hour on 1st and 15th of every month
val hourly = CronSchedule("0 * 1,15 * *")

// Every 15 seconds
val frequently = CronSchedule("*/15 * * * * *")
Value parameters:
fields

cron fields

Returns:

cron schedule

Throws:
IllegalArgumentException

if fields cannot be parsed to a valid schedule