public interface DateParser extends Formatter
Date 对象| 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 对象 |
getLocale, getPattern, getTimeZoneDate parse(String source) throws ParseException
Date 对象
等价于 DateFormat.parse(String)source - 日期字符串DateParseException - 转换异常,被转换的字符串格式错误Date parse(String source, ParsePosition pos)
Date 对象
等价于 DateFormat.parse(String, ParsePosition)source - 日期字符串pos - ParsePositionDateboolean parse(String source, ParsePosition pos, Calendar calendar)
source - 被转换的日期字符串pos - 定义开始转换的位置,转换结束后更新转换到的位置calendar - 用于设置已解析字段的日历IllegalArgumentException - 当日历被设置为不宽松,并且已解析字段超出范围时Object parseObject(String source) throws ParseException
Date 对象source - 应该解析其开头的字符串ParseException - 如果无法解析指定字符串的开头Format.parseObject(String)Object parseObject(String source, ParsePosition pos)
ParsePosition 给定将日期字符串解析并转换为 Date 对象source - 应该解析其开头的字符串pos - 解析的位置DateFormat.parseObject(String, ParsePosition)Copyright © 2020. All rights reserved.