org.weborganic.bastille.cache.util
Class HttpDateFormat

java.lang.Object
  extended by org.weborganic.bastille.cache.util.HttpDateFormat

public final class HttpDateFormat
extends Object

A date format to produce and parse dates compliant with the RFC 2616 - HTTP/1.1 protocol.

Section 3.3.1 defines the preferred full date and time as:

 HTTP-date    = rfc1123-date
 rfc1123-date = wkday "," SP date1 SP time SP "GMT"
 date1        = 2DIGIT SP month SP 4DIGIT
 ; day month year (e.g., 02 Jun 1982)
 time         = 2DIGIT ":" 2DIGIT ":" 2DIGIT
 ; 00:00:00 - 23:59:59
 wkday        = "Mon" | "Tue" | "Wed"
 | "Thu" | "Fri" | "Sat" | "Sun"
 month        = "Jan" | "Feb" | "Mar" | "Apr"
 | "May" | "Jun" | "Jul" | "Aug"
 | "Sep" | "Oct" | "Nov" | "Dec"
 

For example: Sun, 07 Jan 2013 04:17:56 GMT


Constructor Summary
HttpDateFormat()
          Creates a new formatter.
 
Method Summary
 String format(Date date)
          Formats the specified date.
 Date parse(String date)
          Parses dates supplied in accordance with Section 3.3.1 of RFC 2616
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpDateFormat

public HttpDateFormat()
Creates a new formatter.

Method Detail

format

public String format(Date date)
Formats the specified date.

Parameters:
date - The date to format
Returns:
A date formatted in accordance with Section 3.3.1 of RFC 2616

parse

public Date parse(String date)
Parses dates supplied in accordance with Section 3.3.1 of RFC 2616

If the date cannot be parsed, the start of POSIX time, 1/1/1970 is returned, which will have the effect of expiring the content.

Parameters:
date - a date formatted in accordance with Section 3.3.1 of RFC 2616
Returns:
the parsed date or 0L