У меня есть список записей cron в моей базе данных, в котором есть только значения для даты, дня месяца, дня недели.
Примеры значений cron в моей базе данных. «0 0 * * * " " * * 15 2 " " * * * * ПН-ПТ»
Как мне проверить, есть ли в моей базе данных какая-либо запись cron, которая применима на сегодняшний день? Я должен использовать это в моем приложении загрузки java spring.




You can use cronexpression of quartz to get for next valid fire date of cron.
Ex.
String orgTimeZone = "US/Eastern";
String cron = "0 10 2 ? * MON,WED *";
CronExpression exp = new CronExpression(cron);
exp.setTimeZone(TimeZone.getTimeZone(orgTimeZone));
Date date = new Date();
Date nextValidFireTime = exp.getNextValidTimeAfter(date);
ZonedDateTime nextExecDate = zonedDateTimeConverter.toZonedDateTime(nextValidFireTime, orgTimeZone);
ZonedDateTime currentDate = zonedDateTimeConverter.toZonedDateTime(date, orgTimeZone);
System.out.println(nextExecDate);
ZonedDateTime after1Hourdate = currentDate.plusHours(1);
System.out.println(currentDate + ":" + after1Hourdate);
if (nextExecDate.isAfter(currentDate) && nextExecDate.isBefore(after1Hourdate)) {
System.out.println("Match Cron");
}
попробуйте изучить cron-parser cron-parser.com, это может помочь вам решить эту проблему.