-
Notifications
You must be signed in to change notification settings - Fork 83
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
Conversation
Ok, this, I think, does need to go in 2.20 not 2.19(.1) due to minor changes to internal API, behavior. |
@@ -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)) { |
There was a problem hiding this comment.
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))) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, make sense 👍🏼
/** | ||
* @deprecated since 2.20 Use {@link #createFormatter(SerializerProvider, DateTimeZone)} instead | ||
*/ | ||
@Deprecated // since 2.20 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Fixes #92 and #146