Module bus.core

Class TimeParser

java.lang.Object
org.miaixz.bus.core.center.date.format.parser.TimeParser
All Implemented Interfaces:
Serializable, Predicate<CharSequence>, DateParser, PredicateDateParser

public class TimeParser extends Object implements PredicateDateParser, Serializable
时间日期字符串,日期默认为当天,支持格式类似于;
   HH:mm:ss
   HH:mm
 
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Field Details

    • INSTANCE

      public static final TimeParser INSTANCE
      单例实例
  • Constructor Details

    • TimeParser

      public TimeParser()
  • Method Details

    • test

      public boolean test(CharSequence date)
      测试字符串是否符合时间格式。
      Specified by:
      test in interface Predicate<CharSequence>
      Parameters:
      date - 时间字符串
      Returns:
      是否匹配时间格式
    • parse

      public DateTime parse(CharSequence source)
      解析时间字符串,默认日期为当天。
      Specified by:
      parse in interface DateParser
      Parameters:
      source - 时间字符串
      Returns:
      解析后的 DateTime 对象