Class FastDateParser
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) Constructs a new FastDateParser.FastDateParser(String pattern, TimeZone timeZone, Locale locale, Date centuryStart) Constructs a new FastDateParser. -
Method Summary
Modifier and TypeMethodDescriptionparse(CharSequence source) 将日期字符串解析并转换为Date对象parse(CharSequence source, ParsePosition pos) 将日期字符串解析并转换为Date对象 等价于DateFormat.parse(String, ParsePosition)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, getTimeZone
-
Constructor Details
-
FastDateParser
Constructs a new FastDateParser.
Use
FormatBuilder.getInstance(String, TimeZone, Locale)or another variation of the factory methods ofFormatBuilderto get a cached FastDateParser instance.- Parameters:
pattern- non-nullSimpleDateFormatcompatible patterntimeZone- non-null time zone to uselocale- non-null locale
-
FastDateParser
Constructs a new FastDateParser.
- Parameters:
pattern- non-nullSimpleDateFormatcompatible patterntimeZone- non-null time zone to uselocale- non-null localecenturyStart- The start of the century for 2 digit year parsing
-
-
Method Details
-
parse
Description copied from interface:DateParser将日期字符串解析并转换为Date对象- Specified by:
parsein interfaceDateParser- Parameters:
source- 被解析的日期字符串- Returns:
Date对象- Throws:
DateException- 转换异常,被转换的字符串格式错误。
-
parse
Description copied from interface:PositionDateParser将日期字符串解析并转换为Date对象 等价于DateFormat.parse(String, ParsePosition)- Specified by:
parsein interfacePositionDateParser- Parameters:
source- 日期字符串pos-ParsePosition- Returns:
Date
-
parse
Description copied from interface:PositionDateParser- Specified by:
parsein interfacePositionDateParser- Parameters:
source- 被转换的日期字符串pos- 定义开始转换的位置,转换结束后更新转换到的位置calendar- 解析并更新的Calendar- Returns:
- 解析成功返回
true,否则返回false
-