【修复】定时任务指定某一年执行时,只会执行一次,后台查看任务详细会报错

Signed-off-by: 高高 <171376172@qq.com>
This commit is contained in:
高高 2024-06-06 10:01:47 +00:00 committed by Gitee
parent 97e8c35f70
commit 5e0a8b44c4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -46,6 +46,10 @@ public class CronUtils {
List<LocalDateTime> nextTimes = new ArrayList<>(n); List<LocalDateTime> nextTimes = new ArrayList<>(n);
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
Date nextTime = cron.getNextValidTimeAfter(now); Date nextTime = cron.getNextValidTimeAfter(now);
if (nextTime == null) {
// 如果 nextTime null说明没有更多的有效时间退出循环
break;
}
nextTimes.add(LocalDateTimeUtil.of(nextTime)); nextTimes.add(LocalDateTimeUtil.of(nextTime));
// 切换现在为下一个触发时间 // 切换现在为下一个触发时间
now = nextTime; now = nextTime;