Package org.geotools.util
Class DateTimeParser
Object
DateTimeParser
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
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
FLAG to return current time when the String to be parsed is "current"static final int
FLAG to return current time when the String to be parsed is "now"static final int
FLAG to return current time when the String to be parsed is "present"static final int
FLAG allowing Lenient ISO8601 format alternatives, for example, YYYYMMdd in addition to YYYY-MM-dd).static final int
FLAG to return a validity date range for dates with reduced precisionstatic final String[]
static final String[]
static final String[]
static final String[]
static final String[]
static final String[]
static final String[]
static final long
Amount of milliseconds in a day.static final TimeZone
UTC timezone to serve as reference -
Constructor Summary
ConstructorsConstructorDescriptionBuilds a default TimeParser with no provided maximum number of timesDateTimeParser
(int maxTimes) Parses times throwing an exception if the final list exceeds maxTimesDateTimeParser
(int maxTimes, int flags) Parses times throwing an exception if the final list exceeds maxTimes -
Method Summary
Modifier and TypeMethodDescriptionvoid
checkMaxTimes
(Set result, int maxValues) Parses the date given in parameter.static long
parsePeriod
(String period) Parses the increment part of a period and returns it in milliseconds.
-
Field Details
-
FLAG_GET_TIME_ON_PRESENT
public static final int FLAG_GET_TIME_ON_PRESENTFLAG 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_NOWFLAG 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_CURRENTFLAG to return current time when the String to be parsed is "current"- See Also:
-
FLAG_IS_LENIENT
public static final int FLAG_IS_LENIENTFLAG 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_DATERANGEFLAG to return a validity date range for dates with reduced precision- See Also:
-
LENIENT_FORMATS_MILLISECOND
-
LENIENT_FORMATS_SECOND
-
LENIENT_FORMATS_MINUTE
-
LENIENT_FORMATS_HOUR
-
LENIENT_FORMATS_DAY
-
LENIENT_FORMATS_MONTH
-
LENIENT_FORMATS_YEAR
-
UTC_TZ
UTC timezone to serve as reference -
MILLIS_IN_DAY
public static final long MILLIS_IN_DAYAmount 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 limitflags
- a combination (bitwise OR) of FLAG_XXX to customize the parsing.
-
-
Method Details
-
parse
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 thevalue
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
-
parsePeriod
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.
-