public final class CronExpression extends Object
CronExpression
instances are created through
parse(String)
; the next match is determined with
next(Temporal)
.
CronTrigger
Modifier and Type  Method and Description 

boolean 
equals(Object o) 
int 
hashCode() 
<T extends Temporal & Comparable<? super T>> 
next(T temporal)
Calculate the next
Temporal that matches this expression. 
static CronExpression 
parse(String expression)
Parse the given
crontab expression
string into a
CronExpression . 
String 
toString()
Return the expression string used to create this
CronExpression . 
public static CronExpression parse(String expression)
CronExpression
.
The string has six single spaceseparated time and date fields:
┌───────────── second (059) │ ┌───────────── minute (0  59) │ │ ┌───────────── hour (0  23) │ │ │ ┌───────────── day of the month (1  31) │ │ │ │ ┌───────────── month (1  12) (or JANDEC) │ │ │ │ │ ┌───────────── day of the week (0  7) │ │ │ │ │ │ (0 or 7 is Sunday, or MONSUN) │ │ │ │ │ │ * * * * * *
The following rules apply:
*
), which always stands for
"firstlast". For the "day of the month" or "day of the week" fields, a
question mark (?
) may be used instead of an asterisk.

). The specified range is inclusive.
*
) with /n
specifies
the interval of the number's value through the range.
L
character, which stands for "last", and has a different meaning
in each field:
L
stands for "the last day of the
month". If followed by an negative offset (i.e. Ln
), it means
"n
thtolast day of the month". If followed by W
(i.e.
LW
), it means "the last weekday of the month".
L
stands for "the last day of the
week".
If prefixed by a number or threeletter name (i.e. dL
or
DDDL
), it means "the last day of week d
(or DDD
)
in the month".
nW
, which stands for "the nearest
weekday to day of the month n
".
If n
falls on Saturday, this yields the Friday before it.
If n
falls on Sunday, this yields the Monday after,
which also happens if n
is 1
and falls on a Saturday
(i.e. 1W
stands for "the first weekday of the month").
d#n
(or DDD#n
), which
stands for "the n
th day of week d
(or DDD
) in
the month".
Example expressions:
"0 0 * * * *"
= the top of every hour of every day."*/10 * * * * *"
= every ten seconds."0 0 810 * * *"
= 8, 9 and 10 o'clock of every day."0 0 6,19 * * *"
= 6:00 AM and 7:00 PM every day."0 0/30 810 * * *"
= 8:00, 8:30, 9:00, 9:30, 10:00 and 10:30 every day."0 0 917 * * MONFRI"
= on the hour ninetofive weekdays"0 0 0 25 12 ?"
= every Christmas Day at midnight"0 0 0 L * *"
= last day of the month at midnight"0 0 0 L3 * *"
= thirdtolast day of the month at midnight"0 0 0 1W * *"
= first weekday of the month at midnight"0 0 0 LW * *"
= last weekday of the month at midnight"0 0 0 * * 5L"
= last Friday of the month at midnight"0 0 0 * * THUL"
= last Thursday of the month at midnight"0 0 0 ? * 5#2"
= the second Friday in the month at midnight"0 0 0 ? * MON#1"
= the first Monday in the month at midnightThe following macros are also supported:
"@yearly"
(or "@annually"
) to run un once a year, i.e. "0 0 0 1 1 *"
,"@monthly"
to run once a month, i.e. "0 0 0 1 * *"
,"@weekly"
to run once a week, i.e. "0 0 0 * * 0"
,"@daily"
(or "@midnight"
) to run once a day, i.e. "0 0 0 * * *"
,"@hourly"
to run once an hour, i.e. "0 0 * * * *"
.expression
 the expression string to parseCronExpression
objectIllegalArgumentException
 in the expression does not conform to
the cron format@Nullable public <T extends Temporal & Comparable<? super T>> T next(T temporal)
Temporal
that matches this expression.T
 the type of temporaltemporal
 the seed valuenull
if no such temporal can be found