Java Code Examples for org.quartz.TriggerUtils#computeFireTimes()
The following examples show how to use
org.quartz.TriggerUtils#computeFireTimes() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QssService.java From seed with Apache License 2.0 | 5 votes |
/** * 根据Cron表达式获取接下来的最近几次触发时间 * @param numTimes The number of next fire times to produce * Comment by 玄玉<https://jadyer.cn/> on 2018/11/15 11:02. */ List<Date> getNextFireTimes(String cron, int numTimes) { if(!CronExpression.isValidExpression(cron)){ throw new IllegalArgumentException("CronExpression不正确"); } List<String> list = new ArrayList<>(); CronTriggerImpl cronTriggerImpl = new CronTriggerImpl(); try { cronTriggerImpl.setCronExpression(cron); } catch (ParseException e) { throw new SeedException(CodeEnum.SYSTEM_BUSY.getCode(), "使用表达式["+cron+"]初始化CronTrigger时出错", e); } return TriggerUtils.computeFireTimes(cronTriggerImpl, null, numTimes); }
Example 2
Source File: PageUtils.java From JobX with Apache License 2.0 | 5 votes |
public static List<String> getRecentTriggerTime(String cron) { List<String> list = new ArrayList<String>(); try { CronTriggerImpl cronTriggerImpl = new CronTriggerImpl(); cronTriggerImpl.setCronExpression(cron); List<Date> dates = TriggerUtils.computeFireTimes(cronTriggerImpl, null, 5); for (Date date : dates) { list.add(DateUtils.parseStringFromDate(date,DateUtils.format)); } } catch (ParseException e) { e.printStackTrace(); } return list; }