public class CronPattern extends Object
当为6位时,第一位表示秒,范围0~59,但是第一位不做匹配 当为7位时,最后一位表示年,范围1970~2099,但是第7位不做解析,也不做匹配当定时任务运行到的时间匹配这些表达式后,任务被启动。
当isMatchSecond为true
时才会匹配秒部分
默认都是关闭的
对于每一个子表达式,同样支持以下形式:
间隔(/) > 区间(-) > 列表(,)例如 2,3,6/3中,由于“/”优先级高,因此相当于2,3,(6/3),结果与 2,3,6等价
Constructor and Description |
---|
CronPattern(String pattern)
构造
|
Modifier and Type | Method and Description |
---|---|
boolean |
match(GregorianCalendar calendar,
boolean isMatchSecond)
给定时间是否匹配定时任务表达式
|
boolean |
match(long millis,
boolean isMatchSecond)
给定时间是否匹配定时任务表达式
|
boolean |
match(TimeZone timezone,
long millis,
boolean isMatchSecond)
给定时间是否匹配定时任务表达式
|
String |
toString() |
public CronPattern(String pattern)
pattern
- 表达式public boolean match(long millis, boolean isMatchSecond)
millis
- 时间毫秒数isMatchSecond
- 是否匹配秒true
, 否则返回 false
public boolean match(TimeZone timezone, long millis, boolean isMatchSecond)
timezone
- 时区 TimeZone
millis
- 时间毫秒数isMatchSecond
- 是否匹配秒true
, 否则返回 false
public boolean match(GregorianCalendar calendar, boolean isMatchSecond)
calendar
- 时间isMatchSecond
- 是否匹配秒true
, 否则返回 false
Copyright © 2021. All rights reserved.