CronTriggerImpl cronTriggerImpl = new CronTriggerImpl();
// 这里写要准备猜测的cron表达式
cronTriggerImpl.setCronExpression("0 0 15 5 * ?");
// 20代表最近20次
List<Date> dates = TriggerUtils.computeFireTimes(cronTriggerImpl, null, 20);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
for (int i = 0; i < dates.size(); i++) {
System.out.println(dateFormat.format(dates.get(i)));
}
参考:
本文通过实例演示了如何使用CronTriggerImpl设置cron表达式,并计算出该表达式在未来20次的具体触发时间。这有助于理解cron表达式的格式及其对应的时间触发规则。
3万+

被折叠的 条评论
为什么被折叠?



