james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Non-standart date format parsing by LenientFieldParser.
Date Fri, 30 Sep 2011 14:26:20 GMT
On Fri, 2011-09-30 at 12:32 +0400, gross wrote:
> Hello, all!
> 
> To parse date rfc822 message I use LenientFieldParser, and it
> internally uses DateTimeFieldLenientImpl.PARSER.
> This parser use only one standard date format from DEFAULT_DATE_FORMAT
> const. And there's no usual method to parse non-standard date formats.
> How it can be added to FieldImpl?
> I see a workaround: to parse field manually, not using
> LenientFieldParser, but it seems to be ugly.
> 
> -- Konstantin Gribov aka gross
> 

Konstantin

You can create a custom implementation of DateTimeField parser and plug
it in place of the default one.

LenientFieldParser fieldParser = new LenientFieldParser();
FieldParser<DateTimeField> dateTimeParser = new
MyDateTimeFieldLenientParser();
fieldParser.setFieldParser(FieldName.DATE, dateTimeParser);
fieldParser.setFieldParser(FieldName.RESENT_DATE, dateTimeParser);

Hope this helps

Oleg


Mime
View raw message