Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new SerializationFeature, WRITE_DATES_WITH_ZONE_ID to be used by Date/Time modules #794

Closed
cowtowncoder opened this issue May 15, 2015 · 14 comments
Milestone

Comments

@cowtowncoder
Copy link
Member

note: cleaved off of FasterXML/jackson-datatype-jsr310#15 -- check out that discussion more complete view.

There are conflicting goals regarding serialization of timezone id information. For example:

  • ISO-8601 does not define or support use of timezone ids but only timezone offsets. As such, round-tripping of timezone-aware date/time values will lose timezone identity, even if offset itself is retained
  • Some date/time packages do support inclusion and use of timezone ids, above and beyond ISO-8601 notations. But use of such serializations may limit interoperability.

Introduction of this SerializationFeature would allow explicitly choosing between two options, as the global default.

Note: we may also need per-property overrides. But let's tackled that if and when necessary.

@tommack
Copy link

tommack commented May 15, 2015

Does this feature prescribe a particular format (e.g. https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#ISO_ZONED_DATE_TIME)?

@cowtowncoder
Copy link
Member Author

@tommack if there is consensus on appropriate default format to use, it could and should.

@zkiss
Copy link

zkiss commented May 16, 2015

I'd definitely go with a standardized format, and I'd pick java 8's DateTimeFormatter#ISO_ZONED_DATE_TIME.

@cowtowncoder
Copy link
Member Author

@zkiss Sounds good to me then. I will include this note in javadocs.

One question regarding support: while this is easy to support for JSR-310 module (I assume), and Joda as well I hope, is this something that can easily be supported for basic java.util.Date/Calendar?

cowtowncoder added a commit that referenced this issue May 18, 2015
cowtowncoder added a commit that referenced this issue May 18, 2015
@zkiss
Copy link

zkiss commented May 19, 2015

@cowtowncoder That's a good question. Haven't looked into this, but in theory it is possible that even joda ans jsr310 have differences in time zone identifiers. Typos or different namings are possible (although I'd assume with a low chance). Regarding the old java date API a quick search suggests to me it also supports standardized time zone names.

Because of this, I'd first assume there are no differences, maybe check some of them manually, then deal with bugs later as needed.

@cowtowncoder
Copy link
Member Author

@zkiss Fair enough. We can assume it is fair to expect this format -- while it is not the safest choice (might prove to be wrong), there isn't much value in saying "what this really means depends entirely on module".

@tommack
Copy link

tommack commented May 20, 2015

If both WRITE_DATES_WITH_ZONE_ID and WRITE_DATES_AS_TIMESTAMPS are true, is WRITE_DATES_WITH_ZONE_ID ignored?

@cowtowncoder
Copy link
Member Author

@tommack Yes. WRITE_DATES_WITH_ZONE_ID is only relevant when serialization format is textual. Another way to indicate serialize-as-timestamp is to use @JsonFormat(shape=NUMBER) (vs shape=STRING).

@cowtowncoder cowtowncoder added this to the 2.6.0 milestone Jun 2, 2015
@cowtowncoder
Copy link
Member Author

Feature itself added; use is up to modules: jsr-310 module uses this, but Joda not yet.

@zkiss
Copy link

zkiss commented Jun 3, 2015

@cowtowncoder AFAIK jsr310 still does not use the feature (I've just checked branch master to make sure). In order to use it serializers (and maybe deserializers as well) should be modified.

@cowtowncoder
Copy link
Member Author

Oh. So the merge was only for separating different modules without functional difference yet?

@zkiss
Copy link

zkiss commented Jun 3, 2015

JSR310Module and JavaTimeModule behave differently by registering a different class for ZonedDateTime serialization - short term solution.

Long term solution is still to be implemented, by modifying the serializer registered by JavaTimeModule to use this Feature.

@cowtowncoder
Copy link
Member Author

@zkiss ah ok. I will actually reopen this then as a reminder, although separate issues are needed for modules.

@cowtowncoder
Copy link
Member Author

Implemented for Joda module for 2.6.0, closing.

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

No branches or pull requests

3 participants