-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Fix DateFormat
time zone is not restored.
#2548
Conversation
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.
This looks good, but can you add a test that fails without this change and passes with it?
import java.util.Date; | ||
import java.util.List; | ||
import java.util.Locale; | ||
import java.util.*; |
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.
Your IDE probably did this for you, but please undo it. :-)
This project follows the Google Java Style Guide, notably the bit excluding wildcard imports.
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.
Oh, Idea change it automatically.
Just as forewarning: This change conflicts with #2546, so one of the PRs will cause conflicts for the other one. Also this affects more classes:
If you don't want to change these yet, I can do that in a follow-up PR. Some additional notes:
|
ok, I change title and pr's description. About other classes need to be changed, I will do it in next week. |
yes, I add the test, and find my change can not fix the bug. I will debug to find how to fix. |
there are some issue in my local Idea, I can’t fetch new branch. I will close the issue and make a new pr when I finished the development. |
Purpose
Fix
DateFormat
time zone is not restored after parsing. About issue is #2547Description
Before attempting to parse the date string, save the current timezone for each DateFormat object. Use a
finally
block to ensure that the original timezone is restored for each DateFormat object.Checklist
This is automatically checked by
mvn verify
, but can also be checked on its own usingmvn spotless:check
.Style violations can be fixed using
mvn spotless:apply
; this can be done in a separate commit to verify that it did not cause undesired changes.null
@since $next-version$
(
$next-version$
is a special placeholder which is automatically replaced during release)TestCase
)mvn clean verify javadoc:jar
passes without errors