commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Duncan Jones (JIRA)" <>
Subject [jira] [Commented] (LANG-799) DateUtils#parseDate uses default locale; add Locale support
Date Sat, 22 Sep 2012 17:24:07 GMT


Duncan Jones commented on LANG-799:

bq. Does not fail for me, even if I change the default Locale to Locale.GERMAN(Y)

This appears to be related to Java version. I was inadvertently compiling and executing the
tests with JDK 7 not 6. The test passes under 6 and fails under 7.
> DateUtils#parseDate uses default locale; add Locale support
> -----------------------------------------------------------
>                 Key: LANG-799
>                 URL:
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.time.*
>    Affects Versions: 3.1
>            Reporter: Oliver Kopp
>            Priority: Minor
>              Labels: features
>             Fix For: 3.2
>         Attachments: commons-lang3-LANG-799.patch
>   Original Estimate: 2h
>  Remaining Estimate: 2h
> Similar issue as
> Following line throws an ParseException on a German system:
> d = DateUtils.parseDate("Wed, 09 Apr 2008 23:55:38 GMT", new String[] {"EEE, dd MMM yyyy
HH:mm:ss zzz"});
> Reason: parseDate internally calls SimpleDateFormat without providing a locale. This
causes "MMM" to be interpreted using the system locale. If the system is German, the date
is trying to be interpreted as German date.
> I see following solutions:
>  A) Always instantiate SimpleDateFormat with Locale.ENGLISH
>  B) Make two instances of SimpleDateFormat. One without providing a locale and one with
Locale.ENGLISH. Try two parsings
>  C) Make as many SimpleDateFormat instances as locales are availble iterate over all
instances at the parsing attempts.
>  D) provide an additional (optional) parameter to parseDate for providing a Locale
> I would prefer B) as this seems the best trade-off between internationalization and local
> What do you think?

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message