其他分享
首页 > 其他分享> > 根据cron规则获取下次执行时间

根据cron规则获取下次执行时间

作者:互联网

之前有个需求,根据规则生成定时任务

public static long getNextTriggerTime(String cron){
if(!CronExpression.isValidExpression(cron)){
return 0;
}
CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(“Caclulate Date”).withSchedule(CronScheduleBuilder.cronSchedule(cron)).build();
Date time0 = trigger.getStartTime();
Date time1 = trigger.getFireTimeAfter(time0);
return time1.getTime();
}

标签:下次,return,time0,time1,cron,获取,trigger,Date
来源: https://blog.csdn.net/weixin_43863128/article/details/120885802