public final class CronUtils extends Object
Scheduler,所有定时任务在同一个调度器中执行
setMatchSecond(boolean) 方法用于定义是否使用秒匹配模式,如果为true,则定时任务表达式中的第一位为秒,否则为分,默认是分| Modifier and Type | Field and Description |
|---|---|
static String |
CRONTAB_CONFIG_PATH
Crontab配置文件
|
| Modifier and Type | Method and Description |
|---|---|
static Scheduler |
getScheduler() |
static List<Date> |
matchedDates(CronPattern pattern,
long start,
long end,
int count,
boolean isMatchSecond)
列举指定日期范围内所有匹配表达式的日期
|
static List<Date> |
matchedDates(String patternStr,
Date start,
Date end,
int count,
boolean isMatchSecond)
列举指定日期范围内所有匹配表达式的日期
|
static List<Date> |
matchedDates(String patternStr,
Date start,
int count,
boolean isMatchSecond)
列举指定日期之后(到开始日期对应年年底)内所有匹配表达式的日期
|
static List<Date> |
matchedDates(String patternStr,
long start,
long end,
int count,
boolean isMatchSecond)
列举指定日期范围内所有匹配表达式的日期
|
static void |
remove(String schedulerId)
移除任务
|
static void |
restart()
重新启动定时任务
此方法会清除动态加载的任务,重新启动后,守护线程与否与之前保持一致
|
static void |
schedule(Setting cronSetting)
批量加入配置文件中的定时任务
|
static String |
schedule(String schedulingPattern,
Runnable task)
加入定时任务
|
static String |
schedule(String id,
String schedulingPattern,
Task task)
加入定时任务
|
static String |
schedule(String schedulingPattern,
Task task)
加入定时任务
|
static void |
setCronSetting(Setting cronSetting)
自定义定时任务配置文件
|
static void |
setCronSetting(String cronSettingPath)
自定义定时任务配置文件路径
|
static void |
setMatchSecond(boolean isMatchSecond)
设置是否支持秒匹配
此方法用于定义是否使用秒匹配模式,如果为true,则定时任务表达式中的第一位为秒,否则为分,默认是分
|
static void |
start()
开始,非守护线程模式
|
static void |
start(boolean isDeamon)
开始
|
static void |
stop()
停止
|
static void |
updatePattern(String id,
CronPattern pattern)
移除Task
|
public static final String CRONTAB_CONFIG_PATH
public static void setCronSetting(Setting cronSetting)
cronSetting - 定时任务配置文件public static void setCronSetting(String cronSettingPath)
cronSettingPath - 定时任务配置文件路径(相对绝对都可)public static void setMatchSecond(boolean isMatchSecond)
isMatchSecond - true支持,false不支持public static String schedule(String schedulingPattern, Task task)
schedulingPattern - 定时任务执行时间的crontab表达式task - 任务public static String schedule(String id, String schedulingPattern, Task task)
id - 定时任务IDschedulingPattern - 定时任务执行时间的crontab表达式task - 任务public static String schedule(String schedulingPattern, Runnable task)
schedulingPattern - 定时任务执行时间的crontab表达式task - 任务public static void schedule(Setting cronSetting)
cronSetting - 定时任务设置文件public static void remove(String schedulerId)
schedulerId - 任务IDpublic static void updatePattern(String id, CronPattern pattern)
id - Task的IDpattern - CronPatternpublic static Scheduler getScheduler()
public static void start()
start(boolean)public static void start(boolean isDeamon)
isDeamon - 是否以守护线程方式启动,如果为true,则在调用stop()方法后执行的定时任务立即结束,否则等待执行完毕才结束public static void restart()
public static void stop()
public static List<Date> matchedDates(String patternStr, Date start, int count, boolean isMatchSecond)
patternStr - 表达式字符串start - 起始时间count - 列举数量isMatchSecond - 是否匹配秒public static List<Date> matchedDates(String patternStr, Date start, Date end, int count, boolean isMatchSecond)
patternStr - 表达式字符串start - 起始时间end - 结束时间count - 列举数量isMatchSecond - 是否匹配秒public static List<Date> matchedDates(String patternStr, long start, long end, int count, boolean isMatchSecond)
patternStr - 表达式字符串start - 起始时间end - 结束时间count - 列举数量isMatchSecond - 是否匹配秒public static List<Date> matchedDates(CronPattern pattern, long start, long end, int count, boolean isMatchSecond)
pattern - 表达式start - 起始时间end - 结束时间count - 列举数量isMatchSecond - 是否匹配秒Copyright © 2019. All rights reserved.