java.lang.Object
org.miaixz.bus.core.center.date.printer.SimpleDatePrinter
org.miaixz.bus.core.center.date.format.parser.FastDateParser
- All Implemented Interfaces:
Serializable,DateParser,PositionDateParser,DatePrinter
线程安全的日期解析器,替代
SimpleDateFormat,用于将日期字符串转换为 Date 对象。- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Field Summary
Fields inherited from class org.miaixz.bus.core.center.date.printer.SimpleDatePrinter
locale, pattern, timeZone -
Constructor Summary
ConstructorsConstructorDescriptionFastDateParser(String pattern, TimeZone timeZone, Locale locale) 构造FastDateParser实例,推荐使用FormatBuilder的工厂方法获取缓存实例。FastDateParser(String pattern, TimeZone timeZone, Locale locale, Date centuryStart) 构造FastDateParser实例,允许指定世纪起始时间。 -
Method Summary
Modifier and TypeMethodDescriptionparse(CharSequence source) 解析日期字符串。booleanparse(CharSequence source, ParsePosition pos, Calendar calendar) 解析日期字符串到日历对象。Methods inherited from class org.miaixz.bus.core.center.date.printer.SimpleDatePrinter
equals, getLocale, getPattern, getTimeZone, hashCode, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.miaixz.bus.core.center.date.printer.DatePrinter
getLocale, getPattern, getTimeZoneMethods inherited from interface org.miaixz.bus.core.center.date.format.parser.PositionDateParser
parse, parseCalendar
-
Constructor Details
-
FastDateParser
构造FastDateParser实例,推荐使用FormatBuilder的工厂方法获取缓存实例。- Parameters:
pattern- 非空的SimpleDateFormat兼容格式timeZone- 非空时区locale- 非空地域
-
FastDateParser
构造FastDateParser实例,允许指定世纪起始时间。- Parameters:
pattern- 非空的SimpleDateFormat兼容格式timeZone- 非空时区locale- 非空地域centuryStart- 两位年份解析的世纪起始时间
-
-
Method Details
-
parse
解析日期字符串。- Specified by:
parsein interfaceDateParser- Parameters:
source- 日期字符串- Returns:
- 解析后的日期对象
- Throws:
DateException- 如果解析失败
-
parse
解析日期字符串到日历对象。- Specified by:
parsein interfacePositionDateParser- Parameters:
source- 日期字符串pos- 解析位置calendar- 日历对象- Returns:
- 是否解析成功
-