20149 月15
Cron:表达式在线验证工具
Java 解析Cron表达式,计算执行时间源码:
@At @Ok("raw") public String getCron(@Param("exp") String exp,HttpServletResponse response) { response.setHeader("Content-Type", "text/javascript");//设置跨越访问 $.getScript() List<String> list = new ArrayList<String>(); try { exp= URLDecoder.decode(Strings.sNull(exp),"utf-8"); log.info(exp); CronTriggerImpl cronTriggerImpl = new CronTriggerImpl(); cronTriggerImpl.setCronExpression(exp); Calendar calendar = Calendar.getInstance(); Date now = calendar.getTime(); calendar.add(Calendar.MONTH, 1);//把统计的区间段 List<Date> dates = TriggerUtils.computeFireTimesBetween(cronTriggerImpl, null, now, calendar.getTime());//这个是重点 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); for (int i = 0; i < dates.size(); i++) { if (i > 9) {//这个是提示的日期个数 break; } list.add(dateFormat.format(dates.get(i))); } } catch (Exception e) { } return "var data="+ Json.toJson(list); }
本文地址:https://wizzer.cn/archives/3037 , 转载请保留.
http://www.atool.org/crontab.php 试试这个~~~