You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Andrew Rucker Jones (JIRA)" <ji...@apache.org> on 2016/04/16 12:29:25 UTC
[jira] [Created] (BEANUTILS-486) DateConverter fails when pattern
and locale are set
Andrew Rucker Jones created BEANUTILS-486:
---------------------------------------------
Summary: 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
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.
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
}
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)