Class DateParser

java.lang.Object
org.apache.sling.servlets.post.impl.helper.DateParser

public class DateParser extends Object
Takes a string representation of a time-date string and tries for parse it using different formats.
  • Constructor Details

    • DateParser

      public DateParser()
  • Method Details

    • register

      public void register(String format)
      Registers a format string to the list of internally checked ones. Uses the SimpleDateFormat.
      Parameters:
      format - format as in SimpleDateFormat
      Throws:
      IllegalArgumentException - if the format is not valid.
    • parse

      public Calendar parse(String source)
      Parses the given source string and returns the respective calendar instance. If no format matches returns null.
      Parameters:
      source - date time source string
      Returns:
      calendar representation of the source or null
    • parse

      public Calendar[] parse(String[] sources)
      Parses the given source strings and returns the respective calendar instances. If no format matches for any of the sources returns null.
      Parameters:
      sources - date time source strings
      Returns:
      calendar representations of the source or null