users@jsr311.java.net

Re: Creating date and time formats

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Thu, 31 Jul 2008 10:33:08 -0400

On Jul 27, 2008, at 12:29 PM, Paul Sandoz wrote:

> Markus KARG wrote:
>> The HTTP/1.1 specification uses special formatting for date and
>> time values, e. g. in the Expires-header. It would be great if the
>> response builder API would provide an easy means to create that
>> format, unless there is an .expires(Date) method (currently there
>> is not and resource authors must use SimpleDateFormat
>> and .header("Expires", String) to send it).
>>
>
> The parameter signature of "header" is:
>
> header(String, Object)
>
> So you can pass a Date object for the header value and you can use a
> constant String value for the header name:
>
> Date d = ...
> responseBuilder.header(HttpHeaders.Expires, d);
>
The header method says that it will use the toString method to obtain
a value for the header so I don't think this will work unless we
special case the Date class.

Adding an expires method might be cleaner.

Marc.

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.