zl程序教程

您现在的位置是:首页 >  其他

当前栏目

【转】根据Quartz-Cron表达式获取最近几次执行时间

执行 获取 时间 根据 表达式 最近 quartz Cron
2023-09-27 14:20:55 时间
	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, 8);
			SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			for (Date date : dates) {
				list.add(dateFormat.format(date));
			}
			
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return list;
	}

 转自:https://blog.csdn.net/loveLifeLoveCoding/article/details/80447836