users@jsr311.java.net

Re: Creating date and time formats

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 01 Aug 2008 11:10:53 +0200

Marc Hadley wrote:
> 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.
>

Ah, i implemented it using the HeaderDelegate so it would be consistent
if using the particular methods or the general method.

How about this:

   If there is a HeaderDelegate present for the class of the object use
   that otherwise call the toString method.

?


> Adding an expires method might be cleaner.
>

Agreed, if it is a common case.

Paul.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109