Skip to content

Fix #92 org.joda.DateTime serialization result is not same as Java 8 ZonedDateTime #169

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

Merged
merged 7 commits into from
May 6, 2025

Conversation

JooHyukKim
Copy link
Member

@JooHyukKim JooHyukKim commented May 4, 2025

Fixes #92 and #146

@cowtowncoder
Copy link
Member

Ok, this, I think, does need to go in 2.20 not 2.19(.1) due to minor changes to internal API, behavior.
So target branch is fine: will just need to fix some comments.

@@ -251,6 +266,11 @@ public DateTimeFormatter createFormatter(SerializerProvider ctxt)
formatter = formatter.withZone(DateTimeZone.forTimeZone(tz));
}
}
if (!ctxt.isEnabled(SerializationFeature.WRITE_DATES_WITH_CONTEXT_TIME_ZONE)) {
if (valueTimeZone != null && !valueTimeZone.equals(_jdkTimezone)) {
Copy link
Member

@cowtowncoder cowtowncoder May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this can ever be true as valueTimeZone is Joda's DateTimeZone and _jdkTimeZone is JDK java.util.TimeZone (IDEA flags this as likely flaw).
Should maybe be:

if (valueTimeZone != null && !valueTimeZone.toTimeZone().equals(_jdkTimezone)) {

?

Oh, also maybe null check for _jdkTimeZone to avoid need to convert:

if (valueTimeZone != null) &&
  ((_jdkTimeZone == null) || !valueTimeZone.toTimeZone().equals(_jdkTimezone))) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, make sense 👍🏼

@JooHyukKim JooHyukKim requested a review from cowtowncoder May 6, 2025 04:41
@cowtowncoder cowtowncoder merged commit e84384f into FasterXML:2.x May 6, 2025
9 checks passed
@cowtowncoder cowtowncoder added this to the 2.20.0 milestone May 6, 2025
/**
* @deprecated since 2.20 Use {@link #createFormatter(SerializerProvider, DateTimeZone)} instead
*/
@Deprecated // since 2.20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, looks like there are many references to this now-deprecated method. I'll fix them.

But not 100% sure if this should be deprecated or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove deprecation... I should have reviewed this more carefully; will make some changes in a new PR.

cowtowncoder added a commit that referenced this pull request May 6, 2025
cowtowncoder added a commit that referenced this pull request May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DateTime serialization result is not same as Java 8 ZonedDateTime
2 participants