Class DateTimeParser

Object
DateTimeParser

public class DateTimeParser extends Object
Parses the time parameter of the request. The date, time and period are expected to be formatted according ISO-8601 standard.
Author:
Cedric Briancon, Martin Desruisseaux, Simone Giannecchini, GeoSolutions SAS, Jonathan Meyer, Applied Information Sciences, jon@gisjedi.com, Daniele Romagnoli, GeoSolutions SAS
  • Field Details

    • FLAG_GET_TIME_ON_PRESENT

      public static final int FLAG_GET_TIME_ON_PRESENT
      FLAG to return current time when the String to be parsed is "present"
      See Also:
    • FLAG_GET_TIME_ON_NOW

      public static final int FLAG_GET_TIME_ON_NOW
      FLAG to return current time when the String to be parsed is "now"
      See Also:
    • FLAG_GET_TIME_ON_CURRENT

      public static final int FLAG_GET_TIME_ON_CURRENT
      FLAG to return current time when the String to be parsed is "current"
      See Also:
    • FLAG_IS_LENIENT

      public static final int FLAG_IS_LENIENT
      FLAG allowing Lenient ISO8601 format alternatives, for example, YYYYMMdd in addition to YYYY-MM-dd). See the LENIENT_FORMATS_XXX Constants for a list of supported values
      See Also:
    • FLAG_SINGLE_DATE_AS_DATERANGE

      public static final int FLAG_SINGLE_DATE_AS_DATERANGE
      FLAG to return a validity date range for dates with reduced precision
      See Also:
    • LENIENT_FORMATS_MILLISECOND

      public static final String[] LENIENT_FORMATS_MILLISECOND
    • LENIENT_FORMATS_SECOND

      public static final String[] LENIENT_FORMATS_SECOND
    • LENIENT_FORMATS_MINUTE

      public static final String[] LENIENT_FORMATS_MINUTE
    • LENIENT_FORMATS_HOUR

      public static final String[] LENIENT_FORMATS_HOUR
    • LENIENT_FORMATS_DAY

      public static final String[] LENIENT_FORMATS_DAY
    • LENIENT_FORMATS_MONTH

      public static final String[] LENIENT_FORMATS_MONTH
    • LENIENT_FORMATS_YEAR

      public static final String[] LENIENT_FORMATS_YEAR
    • UTC_TZ

      public static final TimeZone UTC_TZ
      UTC timezone to serve as reference
    • MILLIS_IN_DAY

      public static final long MILLIS_IN_DAY
      Amount of milliseconds in a day.
      See Also:
  • Constructor Details

    • DateTimeParser

      public DateTimeParser()
      Builds a default TimeParser with no provided maximum number of times
    • DateTimeParser

      public DateTimeParser(int maxTimes)
      Parses times throwing an exception if the final list exceeds maxTimes
      Parameters:
      maxTimes - Maximum number of times to parse, or a non positive number to have no limit
    • DateTimeParser

      public DateTimeParser(int maxTimes, int flags)
      Parses times throwing an exception if the final list exceeds maxTimes
      Parameters:
      maxTimes - Maximum number of times to parse, or a non positive number to have no limit
      flags - a combination (bitwise OR) of FLAG_XXX to customize the parsing.
  • Method Details

    • parse

      public Collection parse(String value) throws ParseException
      Parses the date given in parameter. The date format should comply to ISO-8601 standard. The string may contains either a single date, or a start time, end time and a period. In the first case, this method returns a singleton containing only the parsed date. In the second case, this method returns a list including all dates from start time up to the end time with the interval specified in the value string.
      Parameters:
      value - The date, time and period to parse.
      Returns:
      A list of dates, or an empty list of the value string is null or empty.
      Throws:
      ParseException - if the string can not be parsed.
    • checkMaxTimes

      public void checkMaxTimes(Set result, int maxValues)
    • parsePeriod

      public static long parsePeriod(String period) throws ParseException
      Parses the increment part of a period and returns it in milliseconds.
      Parameters:
      period - A string representation of the time increment according the ISO-8601:1988(E) standard. For example: "P1D" = one day.
      Returns:
      The increment value converted in milliseconds.
      Throws:
      ParseException - if the string can not be parsed.