Skip to content
Martin Ledvinka edited this page Jun 26, 2023 · 7 revisions

Date/time handling in JOPA is based on the Java 8 date/time API. The following sections sum up the handling of temporal values.

Datetime

Datetime values are stored as xsd:datetime in an ISO 8601 format with offset (if applicable). JOPA loads them always as OffsetDateTime and transforms them as necessary according to the following table:

Target type Transformation
ZonedDateTime Native transformation OffsetDateTime.toZonedDateTime and ZonedDateTime.toOffsetDateTime are used.
LocalDateTime System timezone offset is determined by JOPA and used to transform to/from OffsetDateTime.
Instant Instant is interpreted as a timestamp at the UTC timezone.
java.util.Date Converted to Instant, i.e., interpreted as a timestamp at the UTC timezone.

Saving the values works in the opposite direction - the value is first transformed to OffsetDateTime and then stored in an ISO 8601 format with offset.

Time

Time values are stored as xsd:time and are basically the time-part of an xsd:dateTime value. That is, they will contain timezone offset. JOPA loads them as OffsetTime and transforms them as necessary according to the following table:

Target type Transformation
LocalTime System timezone offset is determined by JOPA and used to transform to/from OffsetTime

Date

Date values are stored as xsd:date and are always loaded/stored using the LocalDate class.

Duration

Both Java Duration and Period classes are mapped to xsd:duration. When loading the value, JOPA first attempts to parse it as Duration, if it fails (meaning the value is too large for Duration), it is parsed as Period.

Resources

Check out DateTimeUtil and XsdTemporalMapper in the datatype module for details on the implementation.