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 TypeMethodDescription将日期字符串解析并转换为Date对象 等价于DateFormat.parse(String)parse(String source, ParsePosition pos) 将日期字符串解析并转换为Date对象 等价于DateFormat.parse(String, ParsePosition)booleanparse(String source, ParsePosition pos, Calendar calendar) 根据给定格式更新CalendarUpon success, the ParsePosition index is updated to indicate how much of the source text was consumed.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对象 等价于DateFormat.parse(String)- 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根据给定格式更新CalendarUpon success, the ParsePosition index is updated to indicate how much of the source text was consumed. Not all source text needs to be consumed. Upon parse failure, ParsePosition error index is updated to the offset of the source text which does not match the supplied format.- Specified by:
parsein interfacePositionDateParser- Parameters:
source- 被转换的日期字符串pos- 定义开始转换的位置,转换结束后更新转换到的位置calendar- The calendar into which to set parsed fields.- Returns:
- true, if source has been parsed (pos parsePosition is updated); otherwise false (and pos errorIndex is updated)
-