commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Zeckoski <aar...@vt.edu>
Subject Re: Commons lang parseDate fails to parse ISO8601 date?
Date Tue, 08 Sep 2009 14:38:59 GMT
sure thing
https://issues.apache.org/jira/browse/LANG-530
-AZ


On Mon, Sep 7, 2009 at 8:23 PM, Henri Yandell<flamefew@gmail.com> wrote:
> Issue seems to be that DateFormatUtils.ISO_DATETIME objects are
> FastDateFormat objects; whereas parseDate uses SimpleDateFormat. The
> former supports "ZZ" whereas the latter does not.
>
> Java 1.4 (not sure about later) had 'Z' which meant +0100.
> FastDateFormat adds 'ZZ' to support the ISO standard of +01:00. ie)
> presumably your actual value is +0100+0100.
>
> Solution is probably to have parseDate use FastDateFormat, though
> there will always be the issue that getPattern from FastDateFormat may
> not work with SimpleDateFormat.
>
> Could I get you to open up a JIRA issue?
>
> http://issues.apache.org/jira/browse/LANG
>
> Thanks for finding this,
>
> Hen
>
> On Thu, Sep 3, 2009 at 5:32 AM, Aaron Zeckoski<azeckoski@gmail.com> wrote:
>> 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 [399355530@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)
>> ....
>>
>> I am open to absolutely any suggestion as I am completely baffled.
>> -AZ
>>
>>
>> --
>> Aaron Zeckoski (azeckoski (at) vt.edu)
>> Senior Research Engineer - CARET - University of Cambridge
>> https://twitter.com/azeckoski - http://www.linkedin.com/in/azeckoski
>> http://aaronz-sakai.blogspot.com/ - http://tinyurl.com/azprofile
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>



-- 
Aaron Zeckoski (azeckoski (at) vt.edu)
Senior Research Engineer - CARET - University of Cambridge
https://twitter.com/azeckoski - http://www.linkedin.com/in/azeckoski
http://aaronz-sakai.blogspot.com/ - http://tinyurl.com/azprofile

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message