commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Rucker Jones (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (BEANUTILS-486) DateConverter fails when pattern and locale are set
Date Thu, 02 Jun 2016 05:41:59 GMT

    [ https://issues.apache.org/jira/browse/BEANUTILS-486?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15311779#comment-15311779
] 

Andrew Rucker Jones commented on BEANUTILS-486:
-----------------------------------------------

Honestly, no, I wouldn't. I've made very clear what I consider confusing. The developers will
have to decide how to correct their own documentation, or if perhaps the problem truly is
a deficiency in the code, i.e. the derived class not living up to the expectations set by
the base class.

> DateConverter fails when pattern and locale are set
> ---------------------------------------------------
>
>                 Key: BEANUTILS-486
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-486
>             Project: Commons BeanUtils
>          Issue Type: Bug
>          Components: Locale BeanUtils / Converters
>    Affects Versions: 1.9.2
>         Environment: MacOS X 10.11.4
> Java 1.8.0_11
> Default locale: de_DE
>            Reporter: Andrew Rucker Jones
>              Labels: documentation
>
> When using a DateConverter or any of the date conversion classes, setting an explicit
pattern causes the locale to be ignored. The converter seems to think that the locale is only
useful for finding the default pattern for the locale, but that's not true, as the following
code illustrates.
> {code:java}
>     public static void main(String[] args) {
>         SimpleDateFormat sdf = new SimpleDateFormat("MMM dd, yyyy", new Locale("en_US"));
>         ParsePosition pos = new ParsePosition(0);
>         Date result = sdf.parse("Dec 15, 1978", pos);
>         System.out.println(result); // Prints "Fri Dec 15 00:00:00 CET 1978"
>         
>         // Equivalent code should return the same result as the last section
>         DateConverter c = new DateConverter();
>         c.setPattern("MMM dd, yyyy");
>         c.setLocale(new Locale("en_US"));
>         c.convert(Date.class, "Dec 15, 1978"); // Throws ConversionException
>     }
> {code}
> I'm expanding opencsv (opencsv.sourceforge.net), and this bug is breaking my code. I
would really appreciate a speedy resolution.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message