Class FastDateParser

java.lang.Object
org.aoju.bus.core.date.formatter.AbstractMotd
org.aoju.bus.core.date.formatter.FastDateParser
All Implemented Interfaces:
Serializable, DateMotd, DateParser

public class FastDateParser extends AbstractMotd implements DateParser
SimpleDateFormat 的线程安全版本 用于解析日期字符串并转换为 Date 对象
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Constructor Details

  • Method Details

    • parse

      public Date parse(String source) throws ParseException
      Description copied from interface: DateParser
      将日期字符串解析并转换为 Date 对象 等价于 DateFormat.parse(String)
      Specified by:
      parse in interface DateParser
      Parameters:
      source - 日期字符串
      Returns:
      Date
      Throws:
      ParseException - 转换异常,被转换的字符串格式错误
    • parse

      public Date parse(String source, ParsePosition pos)
      Description copied from interface: DateParser
      将日期字符串解析并转换为 Date 对象 等价于 DateFormat.parse(String, ParsePosition)
      Specified by:
      parse in interface DateParser
      Parameters:
      source - 日期字符串
      pos - ParsePosition
      Returns:
      Date
    • parse

      public boolean parse(String source, ParsePosition pos, Calendar calendar)
      Description copied from interface: DateParser
      根据给定格式转换日期字符串 使用解析的字段更新日历。成功之后,将更新ParsePosition索引,以指示消耗了多少源文本。并不是所有的源文本都需要使用 在解析失败时,ParsePosition错误索引将更新为源文本的偏移量,该偏移量与提供的格式不匹配
      Specified by:
      parse in interface DateParser
      Parameters:
      source - 被转换的日期字符串
      pos - 定义开始转换的位置,转换结束后更新转换到的位置
      calendar - 用于设置已解析字段的日历
      Returns:
      如果源已被解析(pos parsePosition 已更新);否则为false(并更新 pos errorIndex)