Package org.gbif.api.util
Class IsoDateInterval
java.lang.Object
org.gbif.api.util.IsoDateInterval
Represents an ISO 8601:2019 date, date-time or date/date-time interval.
Valid serializations include 2023, 2023-08, 2023-08-29, 2023/2024, 2023-08/2023-09 and so on.
-
Constructor Summary
ConstructorsConstructorDescriptionCreate an empty DateRange.IsoDateInterval
(Temporal date) Create a range with bounds ofdate
.IsoDateInterval
(Temporal from, Temporal to) Create a range with boundsfrom
andto
. -
Method Summary
Modifier and TypeMethodDescriptionstatic IsoDateInterval
fromString
(String text) Parses a well-formatted IsoDateInterval from the text representation.static IsoDateInterval
fromString
(String textFrom, String textTo) Parses a well-formatted IsoDateInterval from the text representation.getFrom()
getTo()
void
void
void
void
toString()
Returns the date-time interval formatted as a single value where the from and to values are the same (e.g.toString
(boolean ignoreNonUTCOffset) Returns the date-time interval formatted as a single value where the from and to values are the same (e.g.
-
Constructor Details
-
IsoDateInterval
public IsoDateInterval()Create an empty DateRange. -
IsoDateInterval
Create a range with bounds ofdate
. -
IsoDateInterval
Create a range with boundsfrom
andto
. from and to must have the same type.- Throws:
IllegalArgumentException
- iffrom
is greater thanto
-
-
Method Details
-
getFrom
-
setFrom
-
setFrom
-
getTo
-
setTo
-
setTo
-
toString
Returns the date-time interval formatted as a single value where the from and to values are the same (e.g. "2023"), or as unabbreviated date-times at the defined accuracy otherwise ("2023-08-29/2023-08-30" rather than "2023-08-29/30"). -
toString
Returns the date-time interval formatted as a single value where the from and to values are the same (e.g. "2023"), or as unabbreviated date-times at the defined accuracy otherwise ("2023-08-29/2023-08-30" rather than "2023-08-29/30"). Optionally ignore a non-UTC offset. -
fromString
Parses a well-formatted IsoDateInterval from the text representation.- Throws:
ParseException
-
fromString
Parses a well-formatted IsoDateInterval from the text representation.- Throws:
ParseException
-