Hi,
testDateConversions in TestBeanConverter fails when the system timezone is set to GMT-14 (with dpkg-reconfigure tzdata on Debian/Ubuntu systems).
Here is the error:
Tests run: 28, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.03 sec <<< FAILURE! - in net.sf.practicalxml.converter.bean.TestBeanConverter
testDateConversions(net.sf.practicalxml.converter.bean.TestBeanConverter) Time elapsed: 0.007 sec <<< ERROR!
net.sf.practicalxml.converter.ConversionException: unable to parse: Thu Aug 29 13:12:27 GMT+14:00 2013
at net.sf.practicalxml.converter.bean.Xml2BeanConverter.parseDateDefault(Xml2BeanConverter.java:536)
at net.sf.practicalxml.converter.bean.Xml2BeanConverter.tryConvertAsDate(Xml2BeanConverter.java:304)
at net.sf.practicalxml.converter.bean.Xml2BeanConverter.convertWithoutCast(Xml2BeanConverter.java:156)
at net.sf.practicalxml.converter.bean.Xml2BeanConverter.convertChildren(Xml2BeanConverter.java:480)
at net.sf.practicalxml.converter.bean.Xml2BeanConverter.tryConvertAsBean(Xml2BeanConverter.java:350)
at net.sf.practicalxml.converter.bean.Xml2BeanConverter.convertWithoutCast(Xml2BeanConverter.java:160)
at net.sf.practicalxml.converter.bean.Xml2BeanConverter.convert(Xml2BeanConverter.java:109)
at net.sf.practicalxml.converter.BeanConverter.convertToJava(BeanConverter.java:114)
at net.sf.practicalxml.converter.BeanConverter.convertToJava(BeanConverter.java:96)
at net.sf.practicalxml.converter.bean.TestBeanConverter.testDateConversions(TestBeanConverter.java:488)
Caused by: java.text.ParseException: Unparseable date: "Thu Aug 29 13:12:27 GMT+14:00 2013"
at java.text.DateFormat.parse(DateFormat.java:366)
at net.sf.practicalxml.converter.bean.Xml2BeanConverter.parseDateDefault(Xml2BeanConverter.java:531)
... 31 more
I will take a look at this in the next few days. I'm surprised by the output: it appears to be a standard toString(), whereas I believe it should be ISO 8601 format.
I was unable to reproduce this.
I started by simply trying to parse the specified date on my development machine and was successful, using the following program:
Then I spun up an EC2 instance (AMI: ubuntu-trusty-14.04-amd64-server-20150325), and ran dpkg-reconfigure tzdata to set the timezone to GMT-14. Running the test program (which printed and parsed the current date) I got the following output:
Mon Dec 21 13:19:45 GMT+14:00 2015
It seems strange that I set the timezone to GMT-14 but the output was GMT+14 (when, if anything, I would have expected GMT+10). But the program successfully formatted and parsed the date.
I then built practicalxml using the following JDK installs:
Unless you can provide a specific Java and/or Ubuntu version that causes this this to fail, I have to close the issue.
I managed to reproduce this test failure with:
Last edit: Emmanuel Bourg 2015-12-21
It was actually the French locale setting that did it.
Date.toString() formats strings using en_US always, where DateFormat.parse() attempts to match locale-specific day and month names. Decimal conversions are also affected, as the decimal point is replaced by a comma.
I think that the appropriate solution is to explicitly set the locale on these formats. For decimals it's easy, because that's required by the spec. For dates it's a little less obvious, however the goal is to handle default formatting, and that's what the JDK (currently) does.
Updates made, and released as 1.1.19.
Tested with:
Last edit: Keith D Gregory 2015-12-27