From 7eaddd16f9cec7a4eab5bf036fb56e9efd2b20f0 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 15 Jun 2024 17:57:13 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E5=A4=8D=E3=80=91=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=8C=87=E5=AE=9A=E6=9F=90=E4=B8=80?= =?UTF-8?q?=E5=B9=B4=E6=89=A7=E8=A1=8C=E6=97=B6=EF=BC=8C=E5=8F=AA=E4=BC=9A?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E4=B8=80=E6=AC=A1=EF=BC=8C=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E4=BB=BB=E5=8A=A1=E8=AF=A6=E7=BB=86=E4=BC=9A?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao/framework/quartz/core/util/CronUtils.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-job/src/main/java/cn/iocoder/yudao/framework/quartz/core/util/CronUtils.java b/yudao-framework/yudao-spring-boot-starter-job/src/main/java/cn/iocoder/yudao/framework/quartz/core/util/CronUtils.java index a97a8e1eb..5658fa302 100644 --- a/yudao-framework/yudao-spring-boot-starter-job/src/main/java/cn/iocoder/yudao/framework/quartz/core/util/CronUtils.java +++ b/yudao-framework/yudao-spring-boot-starter-job/src/main/java/cn/iocoder/yudao/framework/quartz/core/util/CronUtils.java @@ -34,24 +34,24 @@ public class CronUtils { * @return 满足条件的执行时间 */ public static List getNextTimes(String cronExpression, int n) { - // 获得 CronExpression 对象 + // 1. 获得 CronExpression 对象 CronExpression cron; try { cron = new CronExpression(cronExpression); } catch (ParseException e) { throw new IllegalArgumentException(e.getMessage()); } - // 从当前开始计算,n 个满足条件的 + // 2. 从当前开始计算,n 个满足条件的 Date now = new Date(); List nextTimes = new ArrayList<>(n); for (int i = 0; i < n; i++) { Date nextTime = cron.getNextValidTimeAfter(now); + // 2.1 如果 nextTime 为 null,说明没有更多的有效时间,退出循环 if (nextTime == null) { - // 如果 nextTime 为 null,说明没有更多的有效时间,退出循环 break; } nextTimes.add(LocalDateTimeUtil.of(nextTime)); - // 切换现在,为下一个触发时间; + // 2.2 切换现在,为下一个触发时间; now = nextTime; } return nextTimes;