diff --git a/src/main/java/com/cronutils/model/definition/CronDefinitionBuilder.java b/src/main/java/com/cronutils/model/definition/CronDefinitionBuilder.java index 05e3c341..dfaeb9b7 100755 --- a/src/main/java/com/cronutils/model/definition/CronDefinitionBuilder.java +++ b/src/main/java/com/cronutils/model/definition/CronDefinitionBuilder.java @@ -332,7 +332,7 @@ private static CronDefinition quartz() { } /** - * Creates CronDefinition instance matching Spring specification. + * Creates CronDefinition instance matching Spring (v5.2 and below) specification. * *

The cron expression is expected to be a string comprised of 6 * fields separated by white space. Fields can contain any of the allowed @@ -384,7 +384,7 @@ private static CronDefinition quartz() { * * * - *

Thus in general Spring cron expressions are as follows: + *

Thus in general Spring cron expressions are as follows (up to version 5.2): * *

S M H DoM M DoW * @@ -402,6 +402,83 @@ private static CronDefinition spring() { .instance(); } + /** + * Creates CronDefinition instance matching Spring (v5.2 onwards) specification. + * https://spring.io/blog/2020/11/10/new-in-spring-5-3-improved-cron-expressions + * + *

The cron expression is expected to be a string comprised of 6 + * fields separated by white space. Fields can contain any of the allowed + * values, along with various combinations of the allowed special characters + * for that field. The fields are as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Field NameMandatoryAllowed ValuesAllowed Special Characters
SecondsYES0-59* , - /
MinutesYES0-59* , - /
HoursYES0-23* , - /
Day of monthYES1-31* ? , - / L W
MonthYES1-12 or JAN-DEC* , -
Day of weekYES0-7 or SUN-SAT* ? , - / L #
+ * + *

Thus in general Spring cron expressions are as follows (from version 5.3 onwards): + * + *

S M H DoM M DoW + * + * @return {@link CronDefinition} instance, never {@code null} + */ + private static CronDefinition spring53() { + return CronDefinitionBuilder.defineCron() + .withSeconds().withValidRange(0, 59).withStrictRange().and() + .withMinutes().withValidRange(0, 59).withStrictRange().and() + .withHours().withValidRange(0, 23).withStrictRange().and() + .withDayOfMonth().withValidRange(1, 31).supportsL().supportsW().supportsLW().supportsQuestionMark().and() + .withMonth().withValidRange(1, 12).and() + .withDayOfWeek().withValidRange(0, 7).withMondayDoWValue(1).withIntMapping(7,0) + .supportsHash().supportsL().supportsQuestionMark().and() + .withSupportedNicknameYearly().withSupportedNicknameAnnually() + .withSupportedNicknameMonthly() + .withSupportedNicknameWeekly() + .withSupportedNicknameDaily().withSupportedNicknameMidnight() + .withSupportedNicknameHourly() + .instance(); + } + /** * Creates CronDefinition instance matching unix crontab specification. *