You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mime4j-dev@james.apache.org by gross <gr...@gmail.com> on 2011/09/30 10:32:17 UTC

Non-standart date format parsing by LenientFieldParser.

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

Re: Non-standart date format parsing by LenientFieldParser.

Posted by Oleg Kalnichevski <ol...@apache.org>.
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