Package org.aoju.bus.core.date.formatter
Class FastDateParser
java.lang.Object
org.aoju.bus.core.date.formatter.AbstractMotd
org.aoju.bus.core.date.formatter.FastDateParser
- All Implemented Interfaces:
Serializable,DateMotd,DateParser
SimpleDateFormat 的线程安全版本
用于解析日期字符串并转换为 Date 对象- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Field Summary
Fields inherited from class org.aoju.bus.core.date.formatter.AbstractMotd
locale, pattern, timeZone -
Constructor Summary
ConstructorsConstructorDescriptionFastDateParser(String pattern, TimeZone timeZone, Locale locale) 构造一个新的FastDateParser 使用FormatBuilder.getInstance(String, TimeZone, Locale)或FormatBuilder工厂方法的另一种变体来获取缓存的FastDateParser实例FastDateParser(String pattern, TimeZone timeZone, Locale locale, Date centuryStart) 构造一个新的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) 根据给定格式转换日期字符串 使用解析的字段更新日历。成功之后,将更新ParsePosition索引,以指示消耗了多少源文本。并不是所有的源文本都需要使用 在解析失败时,ParsePosition错误索引将更新为源文本的偏移量,该偏移量与提供的格式不匹配Methods inherited from class org.aoju.bus.core.date.formatter.AbstractMotd
equals, getLocale, getPattern, getTimeZone, hashCodeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.aoju.bus.core.date.formatter.DateMotd
getLocale, getPattern, getTimeZoneMethods inherited from interface org.aoju.bus.core.date.formatter.DateParser
parseObject, parseObject
-
Constructor Details
-
FastDateParser
构造一个新的FastDateParser 使用FormatBuilder.getInstance(String, TimeZone, Locale)或FormatBuilder工厂方法的另一种变体来获取缓存的FastDateParser实例- Parameters:
pattern- 非空SimpleDateFormat兼容模式timeZone- 非空时区locale- 非空地区
-
FastDateParser
构造一个新的FastDateParser- Parameters:
pattern- 非空SimpleDateFormat兼容模式timeZone- 非空时区locale- 非空地区centuryStart- 本世纪初为2位数年解析
-
-
Method Details
-
parse
Description copied from interface:DateParser将日期字符串解析并转换为Date对象 等价于DateFormat.parse(String)- Specified by:
parsein interfaceDateParser- Parameters:
source- 日期字符串- Returns:
Date- Throws:
ParseException- 转换异常,被转换的字符串格式错误
-
parse
Description copied from interface:DateParser将日期字符串解析并转换为Date对象 等价于DateFormat.parse(String, ParsePosition)- Specified by:
parsein interfaceDateParser- Parameters:
source- 日期字符串pos-ParsePosition- Returns:
Date
-
parse
Description copied from interface:DateParser根据给定格式转换日期字符串 使用解析的字段更新日历。成功之后,将更新ParsePosition索引,以指示消耗了多少源文本。并不是所有的源文本都需要使用 在解析失败时,ParsePosition错误索引将更新为源文本的偏移量,该偏移量与提供的格式不匹配- Specified by:
parsein interfaceDateParser- Parameters:
source- 被转换的日期字符串pos- 定义开始转换的位置,转换结束后更新转换到的位置calendar- 用于设置已解析字段的日历- Returns:
- 如果源已被解析(pos parsePosition 已更新);否则为false(并更新 pos errorIndex)
-