public class DefaultRegexDateParser extends Object implements PredicateDateParser
Modifier and Type | Field and Description |
---|---|
static DefaultRegexDateParser |
INSTANCE
默认实例
|
Constructor and Description |
---|
DefaultRegexDateParser()
构造,初始化默认的解析规则
|
Modifier and Type | Method and Description |
---|---|
DateTime |
parse(CharSequence source)
解析日期,此方法线程安全
|
void |
registerPattern(Pattern pattern)
新增自定义日期正则
|
void |
registerRegex(String regex)
新增自定义日期正则
|
void |
setPreferMonthFirst(boolean preferMonthFirst)
当用户传入的月和日无法判定默认位置时,设置默认的日期格式为dd/mm还是mm/dd
|
boolean |
test(CharSequence charSequence) |
public static DefaultRegexDateParser INSTANCE
public boolean test(CharSequence charSequence)
test
in interface Predicate<CharSequence>
public DateTime parse(CharSequence source)
parse
in interface DateParser
source
- 日期字符串public void setPreferMonthFirst(boolean preferMonthFirst)
preferMonthFirst
- true
默认为mm/dd,否则dd/mmpublic void registerRegex(String regex)
regex
- 日期正则public void registerPattern(Pattern pattern)
pattern
- 日期正则Copyright © 2025. All rights reserved.