package com.glxp.api.util; public class CronUtils { public static String parseSecondIntervel(String time) { int second = Integer.parseInt(time); String cron = "0/" + second + " " + "*" + " " + "* * * ?";//start[1] + "-" + end[1] if (second >= 60) { second = Math.round(second / 60); if (second >= 60) { second = 59; } cron = "0" + " " + "0/" + second + " " + "* * * ?"; } return cron; } public static String parseMinuteIntervel(int time) { int minute = time; String cron = "0" + " " + "0/" + minute + " " + "* * * ?"; if (minute >= 60) { minute = Math.round(minute / 60); if (minute >= 60) { minute = 59; } cron = "0" + " " + "0" + " " + "0/" + minute + " " + "* * ?"; } return cron; } public static String parseHourIntervel(int time) { int hour = time; String cron = "0 0 0/" + hour + " * * ?"; if (time >= 24) { hour = 24; cron = "0 0 0/" + hour + " * * ?"; } return cron; } public static String parseDayIntervel(int time) { int day = time; String cron = "0 0 0 1/" + day + " * ? "; if (time >= 28) { day = 28; cron = "0 0 0 1/" + day + " * ? "; } return cron; } }