public class FastDateParser extends AbstractFormater implements DateParser
SimpleDateFormat 的线程安全版本
用于解析日期字符串并转换为 Date 对象locale, pattern, timeZone| Modifier | Constructor and Description |
|---|---|
protected |
FastDateParser(String pattern,
TimeZone timeZone,
Locale locale)
构造一个新的FastDateParser
使用
FormatBuilder.getInstance(String, TimeZone, Locale)
或FormatBuilder工厂方法的另一种变体来获取缓存的FastDateParser实例 |
protected |
FastDateParser(String pattern,
TimeZone timeZone,
Locale locale,
Date centuryStart)
构造一个新的FastDateParser
|
| Modifier and Type | Method and Description |
|---|---|
Date |
parse(String source)
将日期字符串解析并转换为
Date 对象
等价于 DateFormat.parse(String) |
Date |
parse(String source,
ParsePosition pos)
将日期字符串解析并转换为
Date 对象
等价于 DateFormat.parse(String, ParsePosition) |
boolean |
parse(String source,
ParsePosition pos,
Calendar calendar)
根据给定格式转换日期字符串
使用解析的字段更新日历。成功之后,将更新ParsePosition索引,以指示消耗了多少源文本。并不是所有的源文本都需要使用
在解析失败时,ParsePosition错误索引将更新为源文本的偏移量,该偏移量与提供的格式不匹配
|
Object |
parseObject(String source)
将日期字符串解析并转换为
Date 对象 |
Object |
parseObject(String source,
ParsePosition pos)
根据
ParsePosition 给定将日期字符串解析并转换为 Date 对象 |
equals, getLocale, getPattern, getTimeZone, hashCodeclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitgetLocale, getPattern, getTimeZoneprotected FastDateParser(String pattern, TimeZone timeZone, Locale locale)
FormatBuilder.getInstance(String, TimeZone, Locale)
或FormatBuilder工厂方法的另一种变体来获取缓存的FastDateParser实例pattern - 非空SimpleDateFormat 兼容模式timeZone - 非空时区locale - 非空地区protected FastDateParser(String pattern, TimeZone timeZone, Locale locale, Date centuryStart)
pattern - 非空SimpleDateFormat 兼容模式timeZone - 非空时区locale - 非空地区centuryStart - 本世纪初为2位数年解析public Object parseObject(String source) throws ParseException
DateParserDate 对象parseObject in interface DateParsersource - 应该解析其开头的字符串ParseException - 如果无法解析指定字符串的开头Format.parseObject(String)public Date parse(String source) throws ParseException
DateParserDate 对象
等价于 DateFormat.parse(String)parse in interface DateParsersource - 日期字符串DateParseException - 转换异常,被转换的字符串格式错误public Object parseObject(String source, ParsePosition pos)
DateParserParsePosition 给定将日期字符串解析并转换为 Date 对象parseObject in interface DateParsersource - 应该解析其开头的字符串pos - 解析的位置DateFormat.parseObject(String, ParsePosition)public Date parse(String source, ParsePosition pos)
DateParserDate 对象
等价于 DateFormat.parse(String, ParsePosition)parse in interface DateParsersource - 日期字符串pos - ParsePositionDatepublic boolean parse(String source, ParsePosition pos, Calendar calendar)
DateParserparse in interface DateParsersource - 被转换的日期字符串pos - 定义开始转换的位置,转换结束后更新转换到的位置calendar - 用于设置已解析字段的日历Copyright © 2020. All rights reserved.