public interface DateParser extends DateBasic
Date
对象Modifier and Type | Method and Description |
---|---|
Date |
parse(String source)
|
Date |
parse(String source,
ParsePosition pos)
|
boolean |
parse(String source,
ParsePosition pos,
Calendar calendar)
根据给定格式更新
Calendar
Upon success, the ParsePosition index is updated to indicate how much of the source text was consumed. |
default Object |
parseObject(String source)
将日期字符串解析并转换为
Date 对象 |
default Object |
parseObject(String source,
ParsePosition pos)
|
getLocale, getPattern, getTimeZone
Date parse(String source) throws ParseException
source
- 日期字符串Date
ParseException
- 转换异常,被转换的字符串格式错误。Date parse(String source, ParsePosition pos)
source
- 日期字符串pos
- ParsePosition
Date
boolean parse(String source, ParsePosition pos, Calendar calendar)
Calendar
Upon 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.source
- 被转换的日期字符串pos
- 定义开始转换的位置,转换结束后更新转换到的位置calendar
- The calendar into which to set parsed fields.IllegalArgumentException
- when Calendar has been set to be not lenient, and a parsed field is out of range.default Object parseObject(String source) throws ParseException
Date
对象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)
default Object parseObject(String source, ParsePosition pos)
source
- A String
whose beginning should be parsed.pos
- the parse positionjava.util.Date
objectDateFormat.parseObject(String, ParsePosition)
Copyright © 2024. All rights reserved.