I am using Spring boot application and used spring-boot-starter-quartz.
I have a UNIX cron 0 15 * * 2-6 means run at 3pm on every Tuesday to Saturday. I converted this UNIX cron to Quartz cron 0 0 15 ? * 2-6 as I need to schedule job in Java using Quartz. We cannot have * as dayofMonth as it marks it as invalid cron so we need to mark dayOfMonth as ? and dayOfWeek as 2-6.
As of today, I try to find the nextRunDate of this job using quartz pattern using the below code
CronExpression cronExpression = new CronExpression(quartzCronExpression);
Date nextValidTimeAfter = cronExpression.getNextValidTimeAfter(new Date());
Output is : Mon Jun 10 15:00:00 CEST 2024 which is wrong as it should only run Tuesday to Saturday. Quartz does not seem to give no preference to dayOfMonth here.
Can someone help to get output as Tue Jun 11 15:00:00 CEST 2024 instead?
Comment From: sushmita77
@jhoeller could you pls help?
Comment From: snicoll
@sushmita77 please don't mention team members, we already got a notification when the issue was created.
Comment From: snicoll
Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use the issue tracker only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.
If you're looking for help, https://github.com/jmrozanec/cron-utils could be helpful.