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

Saving/finding Map with Date key (with not english locale) #819

Closed
ghost opened this issue Jul 6, 2015 · 2 comments
Closed

Saving/finding Map with Date key (with not english locale) #819

ghost opened this issue Jul 6, 2015 · 2 comments
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Jul 6, 2015

Bug #558 not fixed.
Morphia version : 1.0.1
System locale : FRENCH.

I got a problem when trying to decode my date "Wed May 06 00:00:00 CEST 2015" : it cannot be decoded using the pattern "EEE MMM dd kk:mm:ss z yyyy" as specified in class "DateConverter" line 45.

The date is encoded using "toString()" method (see class "MapOfValuesConverter" line 55), which according to java.util.Data API documentation uses format "dow mon dd hh:mm:ss zzz yyyy". The day & month name is always written in english.
When decoding using "EEE MMM dd kk:mm:ss z yyyy" pattern in SimpleDateFormatter, the day & month name is written according to system locale (french for me).

To fix this bug, the SimpleDateFormatter declared in DateConverter line 45 should specify which langage to use : replace
new SimpleDateFormat("EEE MMM dd kk:mm:ss z yyyy")
by
new SimpleDateFormat("EEE MMM dd kk:mm:ss z yyyy", Locale.US)

@evanchooly evanchooly added the bug label Jul 6, 2015
@evanchooly evanchooly modified the milestones: post-1.0, 1.1.0 Jul 6, 2015
@ghost
Copy link
Author

ghost commented Jul 6, 2015

Thanks a lot !

@evanchooly
Copy link
Member

np. thanks for tracking down the root cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant