net.sf.ehcache.constructs.web
Class HttpDateFormatter
java.lang.Object
net.sf.ehcache.constructs.web.HttpDateFormatter
public class HttpDateFormatter
- extends Object
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"
An example is Sun, 06 Nov 1994 08:49:37 GMT
These are used in request and response headers.
- Author:
- Greg Luck
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HttpDateFormatter
public HttpDateFormatter()
- Constructs a new formatter.
Note that this class is not thread-safe for use by multiple threads, as SimpleDateFormat is not.
Each thread should create their own instance of this class.
formatHttpDate
public String formatHttpDate(Date date)
- Parameters:
date -
- Returns:
- A date formatted in accordance with Section 3.3.1 of RFC 2616
parseDateFromHttpDate
public Date parseDateFromHttpDate(String date)
- Parses dates supplied in accordance with Section 3.3.1 of RFC 2616
- Parameters:
date - a date formatted in accordance with Section 3.3.1 of RFC 2616
- Returns:
- the parsed Date. 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.
Copyright © 2003-2011 Terracotta, Inc.. All Rights Reserved.