- 
                Notifications
    You must be signed in to change notification settings 
- Fork 17
Date time Handling
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 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.toZonedDateTimeandZonedDateTime.toOffsetDateTimeare used. | 
| LocalDateTime | System timezone offset is determined by JOPA and used to transform to/from OffsetDateTime. | 
| Instant | Instantis 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 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 values are stored as xsd:date and are always loaded/stored using the LocalDate class.
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.
Check out DateTimeUtil and XsdTemporalMapper in the datatype module for details on the implementation.