Interface PositionDateParser

All Superinterfaces:
DateParser, DatePrinter
All Known Implementing Classes:
FastDateParser, FormatBuilder

public interface PositionDateParser extends DateParser
带有ParsePosition的日期解析接口,用于解析日期字符串为 Date 对象
Since:
Java 17+
Author:
Kimi Liu
  • Method Details

    • parse

      Date parse(String source, ParsePosition pos)
      将日期字符串解析并转换为 Date 对象 等价于 DateFormat.parse(String, ParsePosition)
      Parameters:
      source - 日期字符串
      pos - ParsePosition
      Returns:
      Date
    • parse

      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.
      Parameters:
      source - 被转换的日期字符串
      pos - 定义开始转换的位置,转换结束后更新转换到的位置
      calendar - The calendar into which to set parsed fields.
      Returns:
      true, if source has been parsed (pos parsePosition is updated); otherwise false (and pos errorIndex is updated)
      Throws:
      IllegalArgumentException - when Calendar has been set to be not lenient, and a parsed field is out of range.