[ https://issues.apache.org/jira/browse/LANG-530?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henri Yandell closed LANG-530. ------------------------------ Resolution: Fixed Applying the least worst of the various suggestions I've come up with :) svn ci -m "Applying 'fix' for LANG-530. DateUtils.parseDate now protects the common use case of FastDateFormat ZZ output, namely ZZ on the end of the pattern, from being passed to SimpleDateFormat as is. Use of ZZ elsewhere in the pattern isn't protected and will want to consider emulating the String changes made in this patch. " Sending src/java/org/apache/commons/lang3/time/DateUtils.java Sending src/test/org/apache/commons/lang3/time/DateUtilsTest.java Transmitting file data .. Committed revision 891572. > parseDate cannot parse ISO8601 dates produced by FastDateFormat > --------------------------------------------------------------- > > Key: LANG-530 > URL: https://issues.apache.org/jira/browse/LANG-530 > Project: Commons Lang > Issue Type: Bug > Components: lang.time.* > Affects Versions: 2.4 > Reporter: Aaron Zeckoski > Fix For: 3.0 > > Attachments: LANG-530-exception.patch, > LANG-530-protect-SimpleDateFormat.patch > > > I cannot see why this is failing but here is my code: > Date parseDate(String dateStr) { > Date d = null; > if (dateStr != null && ! "".equals(dateStr)) { > try { > // try to parse the date from ISO8601, general > formats, and RFC-2822 > d = DateUtils.parseDate(dateStr, new String[] { > DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern() > }); > } catch (ParseException e) { > // nothing to do > log.info("Failed to parse: " + dateStr + ":" + e, e); > d = null; > } > } > return d; > } > The string I am sending in to that method was generated like this: > String isoDateStr = > DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(date); > The exception is: > 2009-09-03 13:29:37,644 [399355...@qtp3-2] INFO > search.SOLRSearchService - Failed to parse: > 2009-09-03T13:29:30+01:00:java.text.ParseException: Unable to parse > the date: 2009-09-03T13:29:30+01:00 > java.text.ParseException: Unable to parse the date: 2009-09-03T13:29:30+01:00 > at org.apache.commons.lang.time.DateUtils.parseDate(DateUtils.java:285) > at > org.steeple.impl.search.SOLRSearchService.parseDate(SOLRSearchService.java:412) > at > org.steeple.impl.search.SOLRSearchService.execute(SOLRSearchService.java:311) > .... -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.