You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Danny Angus <da...@thought.co.uk> on 2001/10/03 12:05:05 UTC

RFC822Date

I've written new utility class org.apache.james.util.RFC822Date, which
provides two-way conversion of java.util.Date into/out of RFC822 format.
It also deals with timezones more comprehensively than RFC822DateFormat, you
can now specify a timezone other than you local one and convert RFC822 dates
into other timezones.
It has a wide selection of constructors for every contingency and choice of
setters to allow setting by RFC string or Date object.

The no args constructor produces a timestamp.

I felt that it would be of more use to Mailet writers than RFC822DateFormat,
which only works one way, and only uses the default timezone.

It should allow RFC822 date strings to be manipulated as simply as Date
objects.

I hope its some use to someone eventually!
It is javadoc'ed.

d.


---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org


RE: RFC822Date

Posted by Danny Angus <da...@thought.co.uk>.
Harmeet said:
> question: how do you intend to use (String Date) -> (Date object) API.

for comparisons, you might want to have a mailet perform different actions depending on the date a message was sent, perhaps check if that date is obviously wrong, in the future for instance, and you want to correct it, or notify someone.
Perhaps you want to close a mailbox to entries posted after x .. or not accept mail posted before y ..

> The headers often have a format that does not comply with RFC822. 'Date'
> header often does not comply. Part of the 'Recieved' header usu. does, but
> that seems to be a practice not a standard(I think, can anyone confirm)

Date is compulsory and should comply. 
Resent-date is optional (primarily for FW messages, obviously.)
Recieved doesn't mention date at all in the message syntax table, but does excuse it in the description. " time-of-receipt may be specified."

RFC822Date now copes with all of the following cases, are there any more (apart from the two letter "military" time zones which I'm working on) ..
It doesn't work with the zone in front of the year, b'cos that is not allowed by the RFC and I haven't found any examples of it (yet), and after all the class is only claiming to work with dates which *do* comply.

Wed, 3 Oct 2001 06:42:27 GMT+02:10        		gets: Wed, 3 Oct 2001 05:32:27 +0100
Wed 3 Oct 2001 06:42:27 GMT+02:10         		gets: Wed, 3 Oct 2001 05:32:27 +0100
3 Oct 2001 06:42:27 GMT+02:10             		gets: Wed, 3 Oct 2001 05:32:27 +0100

Wed, 3 Oct 2001 06:42:27 PST              		gets: Wed, 3 Oct 2001 15:42:27 +0100
Wed 3 Oct 2001 06:42:27 PST               		gets: Wed, 3 Oct 2001 15:42:27 +0100
3 Oct 2001 06:42:27 PST                   		gets: Wed, 3 Oct 2001 15:42:27 +0100
Wed, 3 October 2001 06:42:27 Pacific Standard Time    gets: Wed, 3 Oct 2001 15:42:27 +0100 

Wed, 3 October 2001 06:42:27 +0100        		gets: Wed, 3 Oct 2001 06:42:27 +0100
Wed 3 October 2001 06:42:27 +0100         		gets: Wed, 3 Oct 2001 06:42:27 +0100
3 October 2001 06:42:27 +0100             		gets: Wed, 3 Oct 2001 06:42:27 +0100
Wed, 3 October 2001 06:42:27 +0100 (BST)  		gets: Wed, 3 Oct 2001 06:42:27 +0100 


d

Re: RFC822Date

Posted by Harmeet <ha...@kodemuse.com>.
question: how do you intend to use (String Date) -> (Date object) API.

The headers often have a format that does not comply with RFC822. 'Date'
header often does not comply. Part of the 'Recieved' header usu. does, but
that seems to be a practice not a standard(I think, can anyone confirm)

I want to extract information like 'Sent Date' and display via HTML pages.
Have had a few problems, but this combination has worked best. I try to
parse the date with each one.
--------------------------------
    private static final DateFormat DF =
        new SimpleDateFormat("EE, d MMM yyyy HH:mm:ss",Locale.US);
    private static final DateFormat DF2 =
        new SimpleDateFormat("d MMM yyyy HH:mm:ss",Locale.US);
    private static final DateFormat DF3 =
        new SimpleDateFormat("EE MMM d HH:mm:ss zzz yyyy",Locale.US);
--------------------

Wondering if anyone knows of an authoritative date field in the headers that
is most likely to comply with RFC822. At present I try this combination in
some order.

Another thing that worries/amuses/irritates me is that Format objects have
rarely exposed but existing multithreading issues. They are also slow.
Does anyone know of a faster and safer alternative ?

thanks,
Harmeet


P.S the CVS checkin
cvs commit: jakarta-james/src/java/org/apache/james/util RFC822Date.java
has this header 'Date: 3 Oct 2001 09:52:44 -0000'
This would not be parsed by <RFC822Date.dx>
:-(

----- Original Message -----
From: "Danny Angus" <da...@thought.co.uk>
To: <ja...@jakarta.apache.org>
Sent: Wednesday, October 03, 2001 3:05 AM
Subject: RFC822Date


> I've written new utility class org.apache.james.util.RFC822Date, which
> provides two-way conversion of java.util.Date into/out of RFC822 format.
> It also deals with timezones more comprehensively than RFC822DateFormat,
you
> can now specify a timezone other than you local one and convert RFC822
dates
> into other timezones.
> It has a wide selection of constructors for every contingency and choice o
f
> setters to allow setting by RFC string or Date object.
>
> The no args constructor produces a timestamp.
>
> I felt that it would be of more use to Mailet writers than
RFC822DateFormat,
> which only works one way, and only uses the default timezone.
>
> It should allow RFC822 date strings to be manipulated as simply as Date
> objects.
>
> I hope its some use to someone eventually!
> It is javadoc'ed.
>
> d.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: james-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org