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

Serialize Instant to BSON datetime when possible #211

Closed
wants to merge 1 commit into from
Closed

Serialize Instant to BSON datetime when possible #211

wants to merge 1 commit into from

Conversation

frost13it
Copy link

For now, only java.util.Date can be serialized to native BSON datetime. This PR makes Instant serializable in this format as well.
But doing so can lead to a loss of precision, so it is performed only when SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS is disabled. Otherwise Instant is serialized the same way as before.

rlodge added a commit that referenced this pull request Mar 26, 2021
rlodge added a commit that referenced this pull request Mar 26, 2021
@rlodge
Copy link
Contributor

rlodge commented Mar 26, 2021

Sorry this has taken so long for me to get to.

I think this is a great feature to have, thanks for putting it together. I wanted to require that it be affirmatively enabled, rather than just relying on WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS. I also wanted to avoid having to modify DBEncoderBsonGenerator because getting the configuration into that location isn't simple. So I tweaked this in a couple of ways and implemented without pulling in this PR.

I'm going to close this, please take a look at the implementation I put in, and if you need something else changed submit a new PR.

@rlodge rlodge closed this Mar 26, 2021
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.

None yet

2 participants