Skip to content

Temporal Data Handling

Martin Ledvinka edited this page Apr 1, 2022 · 2 revisions

Prior to version 0.9.0, the preferred way of handling temporal data was java.util.Date (Date) serialized as the number of milliseconds since Unix epoch. For example:

{
  "http://purl.org/dc/terms/created": 1536304147536
}

Since 0.9.0, ISO 8601-based String serialization of temporal values is preferred. Also, the use of Java 8 date/time API over Date is highly recommended. JB4JSON-LD internally uses OffsetDateTime to represent datetime values (OffsetTime for time and LocalDate for date) and transforms them to relevant types as required (e.g., to LocalDateTime, Instant or Date). When timezone offset operations are required, system default offset is used. For example:

{
  "http://purl.org/dc/terms/modified": "2022-02-24T15:02:32.707Z"
}

Duration values (in Java Duration and Period) are supported as well.

Configuration

The following parameters can be used to configure temporal data handling in JB4JSON-LD:

  • serializeDatetimeAsMillis - configures whether datetime values are serialized as ISO-based String (false, default) or as the number of milliseconds since Unix epoch (true)
  • datetimeFormat - optionally configures the format of datetime values (for both serialization and deserialization) if ISO-based serialization is used. If serializeDatetimeAsMillis is true, this parameter has no effect.

Per-attribute format configuration is currently not supported, but a corresponding issue exists.

Clone this wiki locally