Skip to content

Conversation

mcliedtke
Copy link
Contributor

(continued from: #208 - since I switched branches I opened a different PR)

Adding support for some java 8 java.time classes to (de)serialize to Ion's timestamp type.

Starting with just the following since it seemed pretty clear cut that there could be support:

  • java.time.Instant
  • java.time.OffsetDateTime
  • java.time.ZonedDateTime

I was less sure about how to handle java.time.LocalDate and java.time.LocalDateTime so they have been omitted.

Serialization is fairly straightforward, each class is pretty easily transformed into an Ion timestamp. The caveat is that the transformation for a java.time.ZonedDateTime will be slightly lossy since an Ion timestamp cannot represent the timezone, just the offset. In this case the local offset is used.

Deserialization is also mostly straight forward. In the event that the Ion timestamp's time local offset is unknown (-00:00), then the default timezone is used from the context.

(De)serialization to/from an Ion int or Ion decimal is added as well though I haven't tried to add support to/from an Ion string.


Some of the code could be refined with lambdas and function references in the future if this module is moved to java 8.

…ffsetDateTime, and ZonedDateTime classes. Set JDK version to 8.
@cowtowncoder cowtowncoder merged commit 2ae70d6 into FasterXML:2.12 Jul 1, 2020
@cowtowncoder cowtowncoder added this to the 2.12.0 milestone Jul 1, 2020
@cowtowncoder
Copy link
Member

Merged for 2.12, will add info on release notes

@cowtowncoder
Copy link
Member

Updated README, and also created dataformat-ion team (with @mcliedtke invited) to give push access (it'll be for whole repo, technically, although conceptually for Ion related changes).

@mcliedtke mcliedtke deleted the 2.12_ion_dev branch July 1, 2020 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants