Class DateTimePatterns

java.lang.Object
io.github.connellite.util.internal.dateparse.DateTimePatterns

public class DateTimePatterns extends Object
Safety net for inputs DateTimeScanner does not recognise, such as signed or expanded years.

Formatters are probed with DateTimeFormatter.parseUnresolved(CharSequence, ParsePosition), which reports a mismatch by returning null instead of throwing, so a failing input costs no exceptions. Resolution and range validation are done by ParsedFields, because parseUnresolved deliberately skips both.

This is the last remaining piece of the previous shotgun approach that walked a list of DateTimeFormatters (comparable to what araddon/dateparse explicitly avoids — see ParseAny). It only runs when the scanner returns false.

  • Constructor Details

    • DateTimePatterns

      public DateTimePatterns()
  • Method Details

    • parse

      public static boolean parse(CharSequence text, int start, int end, ParsedFields out)
      Tries every fallback formatter against text between start and end.
      Returns:
      true when one of them consumed the whole range and produced usable fields; when false is returned the contents of out are undefined