Package org.gbif.api.util
Class IsoDateParsingUtils
java.lang.Object
org.gbif.api.util.IsoDateParsingUtils
Utility class that parses date values, the allowed date formats are: "yyyy-MM-dd", "yyyy-MM" or "yyyy".
Note: Does not handle times or time zones. This is used for search queries/predicates with date ranges.
Date ranges are closed at the lower bound, and open at the upper bound, to allow less-than predicates
to match times on the upper bound date (i.e. after midnight).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumerations with the allowed date formats by the occurrence search service. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DateTimeFormatterstatic final Stringstatic final Pattern -
Method Summary
Modifier and TypeMethodDescriptiongetFirstDateFormatMatch(String value) Iterates over all the OccurrenceDateFormat's and returns the first one that parses successfully the value.static LocalDateParses a single date value.parseDateRange(String value) Parses a closed-open range of dates, using the most specific format for each side of the range.static TemporalparseTemporal(String value) Parses an ISO 8601-format date or date-time.static TemporalAccessorstripOffsetOrZone(TemporalAccessor temporalAccessor, boolean ignoreOffset) Remove the offset, either ignoring it or using it to adjust the time.static TemporalAccessorstripOffsetOrZoneExceptUTC(TemporalAccessor temporalAccessor, boolean ignoreOffset) Remove the offset, either ignoring it or using it to adjust the time, unless the offset is 0 (UTC).
-
Field Details
-
SIMPLE_ISO_DATE_STR_PATTERN
- See Also:
-
SIMPLE_ISO_PATTERN
-
ISO_DATE_FORMATTER
-
-
Method Details
-
getFirstDateFormatMatch
public static IsoDateParsingUtils.IsoDateFormat getFirstDateFormatMatch(String value) throws IllegalArgumentException Iterates over all the OccurrenceDateFormat's and returns the first one that parses successfully the value.- Throws:
IllegalArgumentException- in case of unparsable dates
-
parseTemporal
Parses an ISO 8601-format date or date-time. -
parseDate
Parses a single date value. The date is interpreted using the first available date format that successfully parses the value.- Returns:
- the lowest possible date according to the precision given or null in case of *
- Throws:
IllegalArgumentException- in case of unparsable dates
-
parseDateRange
Parses a closed-open range of dates, using the most specific format for each side of the range. Returns null for an unbounded side of the range (*). -
stripOffsetOrZone
public static TemporalAccessor stripOffsetOrZone(TemporalAccessor temporalAccessor, boolean ignoreOffset) Remove the offset, either ignoring it or using it to adjust the time. -
stripOffsetOrZoneExceptUTC
public static TemporalAccessor stripOffsetOrZoneExceptUTC(TemporalAccessor temporalAccessor, boolean ignoreOffset) Remove the offset, either ignoring it or using it to adjust the time, unless the offset is 0 (UTC).
-