ShareYourGroupShareYourGroupCron Helper

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.

FieldRequiredValuesSpecial characters
Secondsyes0-59, - * /
Minutesyes0-59, - * /
Hoursyes0-23, - * /
Day of monthyes1-31, - * ? / L W
Monthyes1-12 or JAN-DEC, - * /
Day of weekyes1-7 or SUN-SAT, - * ? / L #
Yearnoempty 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 #

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.

ExpressionMeaning
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-FRI10:15 on weekdays
0 15 10 L * ?10:15 on the last day of the month
0 15 10 ? * 6L10:15 on the last Friday
0 15 10 ? * 6#310: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.