class FastDateParser extends AbstractDateBasic implements DateParser
| 限定符和类型 | 类和说明 |
|---|---|
private static class |
FastDateParser.CaseInsensitiveTextStrategy
A strategy that handles a text field in the parsing pattern
|
private static class |
FastDateParser.CopyQuotedStrategy
A strategy that copies the static or quoted field in the parsing pattern
|
private static class |
FastDateParser.ISO8601TimeZoneStrategy |
private static class |
FastDateParser.NumberStrategy
A strategy that handles a number field in the parsing pattern
|
private static class |
FastDateParser.PatternStrategy
A strategy to parse a single field from the parsing pattern
|
private static class |
FastDateParser.Strategy
单个日期字段的分析策略
|
private static class |
FastDateParser.StrategyAndWidth
Holds strategy and field width
|
private class |
FastDateParser.StrategyParser
Parse format into Strategies
|
(专用程序包) static class |
FastDateParser.TimeZoneStrategy
A strategy that handles a timezone field in the parsing pattern
|
locale, pattern, timeZone| 限定符 | 构造器和说明 |
|---|---|
protected |
FastDateParser(String pattern,
TimeZone timeZone,
Locale locale)
Constructs a new FastDateParser.
|
protected |
FastDateParser(String pattern,
TimeZone timeZone,
Locale locale,
Date centuryStart)
Constructs a new FastDateParser.
|
| 限定符和类型 | 方法和说明 |
|---|---|
private int |
adjustYear(int twoDigitYear)
使用当前的世纪调整两位数年份为四位数年份
|
private static Map<String,Integer> |
appendDisplayNames(Calendar cal,
Locale locale,
int field,
StringBuilder regex)
Get the short and long values displayed for a field
|
private static ConcurrentMap<Locale,FastDateParser.Strategy> |
getCache(int field)
Get a cache of Strategies for a particular field
|
private FastDateParser.Strategy |
getLocaleSpecificStrategy(int field,
Calendar definingCalendar)
Construct a Strategy that parses a Text field
|
private FastDateParser.Strategy |
getStrategy(char f,
int width,
Calendar definingCalendar)
Obtain a Strategy given a field from a SimpleDateFormat pattern
|
private void |
init(Calendar definingCalendar)
Initialize derived fields from defining fields.
|
private static boolean |
isFormatLetter(char c) |
Date |
parse(String source)
|
Date |
parse(String source,
ParsePosition pos)
|
boolean |
parse(String source,
ParsePosition pos,
Calendar calendar)
根据给定格式转换日期字符串
Updates the Calendar with parsed fields.
|
Object |
parseObject(String source)
将日期字符串解析并转换为
Date 对象 |
Object |
parseObject(String source,
ParsePosition pos)
|
private void |
readObject(ObjectInputStream in)
Create the object after serialization.
|
private static StringBuilder |
simpleQuote(StringBuilder sb,
String value) |
equals, getLocale, getPattern, getTimeZone, hashCode, toStringgetLocale, getPattern, getTimeZoneprivate static final long serialVersionUID
static final Locale JAPANESE_IMPERIAL
private final int century
private final int startYear
private transient List<FastDateParser.StrategyAndWidth> patterns
private static final Comparator<String> LONGER_FIRST_LOWERCASE
private static final ConcurrentMap<Locale,FastDateParser.Strategy>[] caches
private static final FastDateParser.Strategy ABBREVIATED_YEAR_STRATEGY
private static final FastDateParser.Strategy NUMBER_MONTH_STRATEGY
private static final FastDateParser.Strategy LITERAL_YEAR_STRATEGY
private static final FastDateParser.Strategy WEEK_OF_YEAR_STRATEGY
private static final FastDateParser.Strategy WEEK_OF_MONTH_STRATEGY
private static final FastDateParser.Strategy DAY_OF_YEAR_STRATEGY
private static final FastDateParser.Strategy DAY_OF_MONTH_STRATEGY
private static final FastDateParser.Strategy DAY_OF_WEEK_STRATEGY
private static final FastDateParser.Strategy DAY_OF_WEEK_IN_MONTH_STRATEGY
private static final FastDateParser.Strategy HOUR_OF_DAY_STRATEGY
private static final FastDateParser.Strategy HOUR24_OF_DAY_STRATEGY
private static final FastDateParser.Strategy HOUR12_STRATEGY
private static final FastDateParser.Strategy HOUR_STRATEGY
private static final FastDateParser.Strategy MINUTE_STRATEGY
private static final FastDateParser.Strategy SECOND_STRATEGY
private static final FastDateParser.Strategy MILLISECOND_STRATEGY
protected FastDateParser(String pattern, TimeZone timeZone, Locale locale)
Constructs a new FastDateParser.
Use FastDateFormat.getInstance(String, TimeZone, Locale) or another variation of the factory methods of FastDateFormat to get a cached FastDateParser instance.
pattern - non-null SimpleDateFormat compatible patterntimeZone - non-null time zone to uselocale - non-null localeprotected FastDateParser(String pattern, TimeZone timeZone, Locale locale, Date centuryStart)
Constructs a new FastDateParser.
pattern - non-null SimpleDateFormat compatible patterntimeZone - non-null time zone to uselocale - non-null localecenturyStart - The start of the century for 2 digit year parsingprivate void init(Calendar definingCalendar)
definingCalendar - the Calendar instance used to initialize this FastDateParserprivate static boolean isFormatLetter(char c)
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
in - ObjectInputStream from which the object is being deserialized.IOException - if there is an IO issue.ClassNotFoundException - if a class cannot be found.public Object parseObject(String source) throws ParseException
DateParserDate 对象parseObject 在接口中 DateParsersource - A String whose beginning should be parsed.java.util.Date objectParseException - if the beginning of the specified string cannot be parsed.Format.parseObject(String)public Date parse(String source) throws ParseException
DateParserparse 在接口中 DateParsersource - 日期字符串DateParseException - 转换异常,被转换的字符串格式错误。public Object parseObject(String source, ParsePosition pos)
DateParserparseObject 在接口中 DateParsersource - A String whose beginning should be parsed.pos - the parse positionjava.util.Date objectDateFormat.parseObject(String, ParsePosition)public Date parse(String source, ParsePosition pos)
DateParserparse 在接口中 DateParsersource - 日期字符串pos - ParsePositionDatepublic boolean parse(String source, ParsePosition pos, Calendar calendar)
DateParserparse 在接口中 DateParsersource - 被转换的日期字符串pos - 定义开始转换的位置,转换结束后更新转换到的位置calendar - The calendar into which to set parsed fields.private static StringBuilder simpleQuote(StringBuilder sb, String value)
private static Map<String,Integer> appendDisplayNames(Calendar cal, Locale locale, int field, StringBuilder regex)
cal - The calendar to obtain the short and long valueslocale - The locale of display namesfield - The field of interestregex - The regular expression to buildprivate int adjustYear(int twoDigitYear)
twoDigitYear - 两位数年份private FastDateParser.Strategy getStrategy(char f, int width, Calendar definingCalendar)
f - 格式width - 长度definingCalendar - The calendar to obtain the short and long valuesprivate static ConcurrentMap<Locale,FastDateParser.Strategy> getCache(int field)
field - The Calendar fieldprivate FastDateParser.Strategy getLocaleSpecificStrategy(int field, Calendar definingCalendar)
field - The Calendar fielddefiningCalendar - The calendar to obtain the short and long valuesCopyright © 2020. All rights reserved.