Package org.aoju.bus.core.date.formatter
Interface DateParser
- All Superinterfaces:
DateMotd
- All Known Implementing Classes:
FastDateParser,FormatBuilder
日期解析接口,用于解析日期字符串为
Date 对象- Since:
- Java 17+
- Author:
- Kimi Liu
-
Method Summary
Modifier and TypeMethodDescription将日期字符串解析并转换为Date对象 等价于DateFormat.parse(String)parse(String source, ParsePosition pos) 将日期字符串解析并转换为Date对象 等价于DateFormat.parse(String, ParsePosition)booleanparse(String source, ParsePosition pos, Calendar calendar) 根据给定格式转换日期字符串 使用解析的字段更新日历。成功之后,将更新ParsePosition索引,以指示消耗了多少源文本。并不是所有的源文本都需要使用 在解析失败时,ParsePosition错误索引将更新为源文本的偏移量,该偏移量与提供的格式不匹配default ObjectparseObject(String source) 将日期字符串解析并转换为Date对象default ObjectparseObject(String source, ParsePosition pos) 根据ParsePosition给定将日期字符串解析并转换为Date对象Methods inherited from interface org.aoju.bus.core.date.formatter.DateMotd
getLocale, getPattern, getTimeZone
-
Method Details
-
parse
将日期字符串解析并转换为Date对象 等价于DateFormat.parse(String)- Parameters:
source- 日期字符串- Returns:
Date- Throws:
ParseException- 转换异常,被转换的字符串格式错误
-
parse
将日期字符串解析并转换为Date对象 等价于DateFormat.parse(String, ParsePosition)- Parameters:
source- 日期字符串pos-ParsePosition- Returns:
Date
-
parse
根据给定格式转换日期字符串 使用解析的字段更新日历。成功之后,将更新ParsePosition索引,以指示消耗了多少源文本。并不是所有的源文本都需要使用 在解析失败时,ParsePosition错误索引将更新为源文本的偏移量,该偏移量与提供的格式不匹配- Parameters:
source- 被转换的日期字符串pos- 定义开始转换的位置,转换结束后更新转换到的位置calendar- 用于设置已解析字段的日历- Returns:
- 如果源已被解析(pos parsePosition 已更新);否则为false(并更新 pos errorIndex)
- Throws:
IllegalArgumentException- 当日历被设置为不宽松,并且已解析字段超出范围时
-
parseObject
将日期字符串解析并转换为Date对象- Parameters:
source- 应该解析其开头的字符串- Returns:
- 日期对象
- Throws:
ParseException- 如果无法解析指定字符串的开头- See Also:
-
parseObject
根据ParsePosition给定将日期字符串解析并转换为Date对象- Parameters:
source- 应该解析其开头的字符串pos- 解析的位置- Returns:
- 日期对象
- See Also:
-