public class PatternMatcher extends Object
PartMatcher组成,分别是:
0 1 2 3 4 5 6
SECOND MINUTE HOUR DAY_OF_MONTH MONTH DAY_OF_WEEK YEAR
| Constructor and Description |
|---|
PatternMatcher(PartMatcher secondMatcher,
PartMatcher minuteMatcher,
PartMatcher hourMatcher,
PartMatcher dayOfMonthMatcher,
PartMatcher monthMatcher,
PartMatcher dayOfWeekMatcher,
PartMatcher yearMatcher)
构造
|
| Modifier and Type | Method and Description |
|---|---|
PartMatcher |
get(Part part)
根据表达式位置,获取对应的
PartMatcher |
boolean |
match(int[] fields)
给定时间是否匹配定时任务表达式
|
boolean |
matchWeek(int dayOfWeekValue)
给定周的值是否匹配定时任务表达式对应部分
|
Calendar |
nextMatchAfter(int[] values,
TimeZone zone)
获取下一个匹配日期时间
获取方法是,先从年开始查找对应部分的下一个值: 如果此部分下个值不变,获取下一个部分 如果此部分下个值大于给定值,以下所有值置为最小值 如果此部分下个值小于给定值,回退到上一个值获取下一个新值,之后的值置为最小值 秒 分 时 日 月(1) 周(0) 年 下 <-----------------> 上 |
String |
toString() |
public PatternMatcher(PartMatcher secondMatcher, PartMatcher minuteMatcher, PartMatcher hourMatcher, PartMatcher dayOfMonthMatcher, PartMatcher monthMatcher, PartMatcher dayOfWeekMatcher, PartMatcher yearMatcher)
secondMatcher - 秒匹配器minuteMatcher - 分匹配器hourMatcher - 时匹配器dayOfMonthMatcher - 日匹配器monthMatcher - 月匹配器dayOfWeekMatcher - 周匹配器yearMatcher - 年匹配器public PartMatcher get(Part part)
PartMatcherpart - 表达式位置PartMatcherpublic boolean match(int[] fields)
fields - 时间字段值,{second, minute, hour, dayOfMonth, month, dayOfWeek, year}true, 否则返回 falsepublic boolean matchWeek(int dayOfWeekValue)
dayOfWeekValue - dayOfMonth值,星期从0开始,0和7都表示周日true, 否则返回 falsepublic Calendar nextMatchAfter(int[] values, TimeZone zone)
秒 分 时 日 月(1) 周(0) 年
下 <-----------------> 上
values - 时间字段值,{second, minute, hour, dayOfMonth, monthBase1, dayOfWeekBase0, year},
注意这个字段值会被修改zone - 时区Calendar,毫秒数为0Copyright © 2025. All rights reserved.