Quartz cron expressions: six or seven fields (and how Spring differs)
Java programs often use the Quartz format. It looks like cron but has more fields and more symbols, and Spring has a slightly different one.
The fields
The Quartz CronTrigger tutorial says an expression is a string of 6 or 7 fields separated by white space.
| Field | Required | Values | Special characters |
|---|---|---|---|
| Seconds | yes | 0-59 | , - * / |
| Minutes | yes | 0-59 | , - * / |
| Hours | yes | 0-23 | , - * / |
| Day of month | yes | 1-31 | , - * ? / L W |
| Month | yes | 1-12 or JAN-DEC | , - * / |
| Day of week | yes | 1-7 or SUN-SAT | , - * ? / L # |
| Year | no | empty or 1970-2099 | , - * / |
Two things differ from Linux cron at once: the seconds come first, and the days of the week are numbered 1 to 7 with Sunday as 1 (so 6L is the last Friday and 2#1 the first Monday).
The question mark
You must put ? in one of the two day fields. The tutorial calls it "no specific value". If you want the 10th of the month whatever the weekday, you write 10 in the day of month and ? in the weekday. The tutorial also notes that support for specifying both is not complete, so the tool on this page refuses expressions that set both.
L, W and #
- L in the day-of-month field is the last day of the month.
L-3is the third day before the last. In the weekday field,6Lis the last Friday of the month. - W means the weekday nearest the given day:
15Wis the weekday nearest the 15th. If the 15th is a Saturday it fires on Friday the 14th, and if it is a Sunday on Monday the 16th. It never jumps over the month:1Won a Saturday 1st fires on Monday the 3rd.LWis the last weekday of the month. - # means "the nth such day":
6#3is the third Friday of the month. If you ask for#5and the month has only four of that day, nothing fires that month.
Examples, and the tool's answers
All of these are examples from the tutorial; the home page tool reproduces their meaning, and we checked its run times for each against a calendar.
| Expression | Meaning |
|---|---|
0 0 12 * * ? | Every day at 12:00 |
0 0/5 14 * * ? | Every 5 minutes from 14:00 to 14:55 |
0 15 10 ? * MON-FRI | 10:15 on weekdays |
0 15 10 L * ? | 10:15 on the last day of the month |
0 15 10 ? * 6L | 10:15 on the last Friday |
0 15 10 ? * 6#3 | 10:15 on the third Friday |
0 11 11 11 11 ? | Every 11 November at 11:11 |
Converting from Linux cron
Put 0 in front for the seconds, turn one day field into ?, and add 1 to every weekday number. 30 9 * * 1-5 becomes 0 30 9 ? * 2-6, or with names 0 30 9 ? * MON-FRI. The home page tool prints the Quartz form of any Linux expression that has a direct one. If both day fields are set, there is none, because Quartz cannot do the "either" rule.
Spring's version is not the same
Spring's CronExpression class (its documentation, read 13 November 2026) has six fields: second, minute, hour, day of month, month, day of week, and no year field. It follows ordinary cron for the weekday: 0 to 6 for Sunday to Saturday, with 7 also meaning Sunday, or names. The documentation says plainly that Quartz deviates from that convention by using 1 to 7, whereas Spring strictly follows cron, even when combined with the Quartz-style L and #. It accepts ? instead of *, supports the @yearly, @monthly, @weekly, @daily and @hourly macros, and gives examples such as 0 0 0 ? * MON#1 (the first Monday of the month at midnight). So a Spring expression pasted into the Quartz type of the tool can be read wrongly: the same 5 is Friday in Spring and Thursday in Quartz. Use day names when you are not sure which one you have.
Daylight saving
The tutorial warns about firing times in the hours around daylight-saving changes: the shift can cause a skip or a repeat. As with Linux cron, avoid the 1:00 to 3:00 hours in zones with clock changes.
Does Spring use the same format?
Not exactly: see the section above.
Why does Quartz use 1 for Sunday?
It is how the format was defined. Use names (MON-FRI) to avoid the problem.
This is an independent guide and tool. It is not connected with crontab.guru, Quartz, GitHub, Kubernetes, Spring or the Linux projects named here. Product names belong to their owners.