Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 368756 - GitDateFormatter uses wrong locale to create formats
Summary: GitDateFormatter uses wrong locale to create formats
Status: VERIFIED FIXED
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: 1.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 2.0-M1   Edit
Assignee: Dani Megert CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-16 13:37 EST by Dani Megert CLA
Modified: 2012-02-27 05:23 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2012-01-16 13:37:16 EST
1.3.0.201201151914.

The GitDateFormatter uses the default locale to create the formats. This does not work correctly when using JRE 7 or newer where the locale got split into a FORMAT and DISPLAY locale. Hence on an English OS with German set to format dates, it now shows up with English format in the Git History view.

The correct way is to use DateFormat and SimpleDateFormat constructors that don't require the locale.

I can provide the fix but need to know whether it is really need to go via SystemReader.getInstance() (the current code in GitDateFormatter uses it to get the locale and that's the only place where this is done).
Comment 1 Robin Rosenberg CLA 2012-01-16 14:09:41 EST
The main purpose of SystemReader is to provide a hook for unit testing,
so "it depends", but I suggest you use SystemReader for consistency.

Remember the code should work with Java 5 too.
Comment 2 Dani Megert CLA 2012-01-17 04:07:22 EST
(In reply to comment #1)
> The main purpose of SystemReader is to provide a hook for unit testing,
> so "it depends", but I suggest you use SystemReader for consistency.

OK, but we can't use getLocale(). I had to add two new methods to get the DateFormat and the SimpleDateFormat.


> Remember the code should work with Java 5 too.

Yep.

Pushed http://egit.eclipse.org/r/4966 for review.
Comment 3 Dani Megert CLA 2012-02-22 08:59:33 EST
Robin, can you take a look at the comments in the change and reply there?
Thanks.
Comment 4 Matthias Sohn CLA 2012-02-25 18:40:22 EST
merged as 709cd52958e9794827496ce64971a65521ad02d1
Comment 5 Dani Megert CLA 2012-02-27 05:23:22 EST
2.0.0.201202261814.(In reply to comment #4)
> merged as 709cd52958e9794827496ce64971a65521ad02d1

Thanks Matthias!

Verified in 2.0.0.201202261814.