我正在使用石英cron表达式构建n个计划事件,我有开始日期和结束日期,但是,当创建一个表达式时,第二个事件(getNextValidTimeAfter)是错误的...
按照表达式
0 0 8吗? 1/3 FRI#1 *
org.quartz.CronExpression expression = new org.quartz.CronExpression(cronExpression.getExpression());
List<Schedule> scheduleList = new ArrayList<>();
Date nextExecutionDate = cronExpression.getStartDate();
boolean first = true;
while (true) {
Schedule schedule = new Schedule();
schedule.setStatus(Enums.StatusSchedule.PROGRAMADO);
schedule.setCronExpression(cronExpression);
schedule.setServiceOrderType(cronExpression.getServiceOrderType());
schedule.setEstimatedTime(cronExpression.getEstimatedTime());
if (first == false)
nextExecutionDate = expression.getNextValidTimeAfter(nextExecutionDate);
else
first = false;
if (cronExpression.getEndDate().compareTo(nextExecutionDate) <= 0)
break;
schedule.setScheduleDate(nextExecutionDate);
if (CollectionUtils.isEmpty(schedule.getScheduleItems()))
schedule.setScheduleItems(new ArrayList<>());
for (GenericShelfData genericShelfData : genericShelfDataList) {
ScheduleItem scheduleItem = new ScheduleItem();
scheduleItem.setStatus(Enums.StatusSchedule.PROGRAMADO);
scheduleItem.setSchedule(schedule);
scheduleItem.setGenericShelfData(genericShelfData);
scheduleItem.setScheduleSeparate(Enums.YesOrNo.NAO);
schedule.getScheduleItems().add(scheduleItem);
}
scheduleList.add(schedule);
}
答案 0 :(得分:0)
我的表达是错误的...正确是.. 0 0 8吗? 3/3 FRI#2 *
我使用此网站来构建表达式:https://www.freeformatter.com/cron-expression-generator-quartz.html