I am using cron-utils jar for generating cron expression
0 0 8 ? 1/1 5#3 *
3rd Thursday of every month at 8 o' clock
Below is my code for above expression:
CronBuilder withMonth = CronBuilder.cron(
CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ)
).withYear(always()).withDoM(QuestionMark.questionMark())
.withMonth(on(3, SpecialChar.HASH));
withMonth.withDoW(on(5)).withHour(on(8)).withMinute(on(0)).withSecond(on(0));
Cron instance = withMonth.instance();
System.out.println(instance.asString());
But I'm getting the following exception:
value missing for a#b cron expression
finally found solution
.withDoW(on(NUM_DAY_WEEK,SpecialChar.HASH, NUM_DAY_MONTH);
it will generate like 5#3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.