public class FastDateParser extends AbstractDateBasic implements DateParser
FastDatePrinter
,
Serialized Formlocale, pattern, timeZone
Constructor and Description |
---|
FastDateParser(String pattern,
TimeZone timeZone,
Locale locale)
Constructs a new FastDateParser.
|
FastDateParser(String pattern,
TimeZone timeZone,
Locale locale,
Date centuryStart)
Constructs a new FastDateParser.
|
Modifier and Type | Method and Description |
---|---|
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)
|
equals, getLocale, getPattern, getTimeZone, hashCode, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getLocale, getPattern, getTimeZone
public 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 localepublic 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 parsingpublic Object parseObject(String source) throws ParseException
DateParser
Date
对象parseObject
in interface DateParser
source
- 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
DateParser
parse
in interface DateParser
source
- 日期字符串Date
ParseException
- 转换异常,被转换的字符串格式错误。public Object parseObject(String source, ParsePosition pos)
DateParser
parseObject
in interface DateParser
source
- A String
whose beginning should be parsed.pos
- the parse positionjava.util.Date
objectDateFormat.parseObject(String, ParsePosition)
public Date parse(String source, ParsePosition pos)
DateParser
parse
in interface DateParser
source
- 日期字符串pos
- ParsePosition
Date
public boolean parse(String source, ParsePosition pos, Calendar calendar)
DateParser
parse
in interface DateParser
source
- 被转换的日期字符串pos
- 定义开始转换的位置,转换结束后更新转换到的位置calendar
- The calendar into which to set parsed fields.Copyright © 2021. All rights reserved.