Document cron-vs-quartz parsing convention for dayOfWeek part in CronExpression #32128
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: documentation
A documentation task
Milestone
Cron expressions with a quartz specific dayOfWeek part like
0 30 17 ? * 2#3
are not parsed correctly by Spring'sCronExpression
:2#3
means 'third Monday every month' butCronExpression
parses this as "third tuesday in month".It looks like the parsing logic in
QuartzCronField#parseDayOfWeek
is not correct:This methods transforms the input-value (cron/quartz dayOfWeek) into a java.time dayOfWeek index, then returning the corresponding
java.time.DayOfWeek
The problem is, that cron, quartz and java.time have different
dayOfTime
indices. cron and quartz use same indices for su - fr, but Saturday differs. java.time is 1 based, beginning with Monday:So the input-value has to be decremented by 1 and the overflow handled, like this:
Tests:
The text was updated successfully, but these errors were encountered: