Class DateTimePatternDetector

java.lang.Object
com.northconcepts.datapipeline.foundations.time.DateTimePatternDetector

public class DateTimePatternDetector extends Object
A utility for parsing date, time, and date-time values from string using a set of possible patterns. New instances come with a predefined set of common patterns that can be cleared and/or appended to.
  • Constructor Details

    • DateTimePatternDetector

      public DateTimePatternDetector()
  • Method Details

    • isDebug

      public boolean isDebug()
      Indicates if failing patterns should be logged (default false).
    • setDebug

      public DateTimePatternDetector setDebug(boolean debug)
      Indicates if failing patterns should be logged (default false).
    • getPatterns

      public Set<DateTimePattern> getPatterns()
      Returns the live set of patterns, in the order they are tried.
    • addCommonPatterns

      public DateTimePatternDetector addCommonPatterns()
      Adds the built-in common patterns (new detectors already have them); duplicates are ignored.
    • addPattern

      public DateTimePatternDetector addPattern(DateTimePattern pattern)
      Adds a pattern to try after the existing ones; duplicates are ignored.
    • clearPatterns

      public DateTimePatternDetector clearPatterns()
    • addPattern

      public DateTimePatternDetector addPattern(String pattern)
      Adds a case-insensitive DateTimePattern to try after the existing ones; duplicates are ignored.
    • matchFirst

      public DateTimePatternMatch matchFirst(String value)
      Returns the first pattern in this detector that successfully parsed the supplied value.
    • matchAll

      public List<DateTimePatternMatch> matchAll(String value)
      Returns all the patterns in this detector that successfully parsed the supplied value.