Package com.twelvemonkeys.net
Class HTTPUtil
- java.lang.Object
-
- com.twelvemonkeys.net.HTTPUtil
-
public class HTTPUtil extends java.lang.Object
HTTPUtil- Version:
- $Id: HTTPUtil.java,v 1.0 08.09.13 13:57 haraldk Exp$
-
-
Field Summary
Fields Modifier and Type Field Description private static java.text.SimpleDateFormat
HTTP_ASCTIME_FORMAT
ANSI C asctime() date format, (almost) as described in RFC 2616 (HTTP/1.1), sec 3.3.private static java.text.SimpleDateFormat
HTTP_RFC1123_FORMAT
RFC 1123 date format, as recommended by RFC 2616 (HTTP/1.1), sec 3.3 NOTE: All date formats are private, to ensure synchronized access.private static java.text.SimpleDateFormat
HTTP_RFC850_FORMAT
RFC 850 date format, (almost) as described in RFC 2616 (HTTP/1.1), sec 3.3 USE FOR PARSING ONLY (format is not 100% correct, to be more robust).private static long
sNext50YearWindowChange
-
Constructor Summary
Constructors Modifier Constructor Description private
HTTPUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
formatHTTPDate(long pTime)
Formats the time to a HTTP date, using the RFC 1123 format, as described in RFC 2616 (HTTP/1.1), sec.static java.lang.String
formatHTTPDate(java.util.Date pTime)
Formats the time to a HTTP date, using the RFC 1123 format, as described in RFC 2616 (HTTP/1.1), sec.static long
parseHTTPDate(java.lang.String pDate)
Parses a HTTP date string into along
representing milliseconds since January 1, 1970 GMT.private static java.util.Date
parseHTTPDateImpl(java.lang.String pDate)
ParseHTTPDate implementationprivate static void
update50YearWindowIfNeeded()
-
-
-
Field Detail
-
HTTP_RFC1123_FORMAT
private static final java.text.SimpleDateFormat HTTP_RFC1123_FORMAT
RFC 1123 date format, as recommended by RFC 2616 (HTTP/1.1), sec 3.3 NOTE: All date formats are private, to ensure synchronized access.
-
HTTP_RFC850_FORMAT
private static final java.text.SimpleDateFormat HTTP_RFC850_FORMAT
RFC 850 date format, (almost) as described in RFC 2616 (HTTP/1.1), sec 3.3 USE FOR PARSING ONLY (format is not 100% correct, to be more robust).
-
HTTP_ASCTIME_FORMAT
private static final java.text.SimpleDateFormat HTTP_ASCTIME_FORMAT
ANSI C asctime() date format, (almost) as described in RFC 2616 (HTTP/1.1), sec 3.3. USE FOR PARSING ONLY (format is not 100% correct, to be more robust).
-
sNext50YearWindowChange
private static long sNext50YearWindowChange
-
-
Method Detail
-
update50YearWindowIfNeeded
private static void update50YearWindowIfNeeded()
-
formatHTTPDate
public static java.lang.String formatHTTPDate(long pTime)
Formats the time to a HTTP date, using the RFC 1123 format, as described in RFC 2616 (HTTP/1.1), sec. 3.3.- Parameters:
pTime
- the time- Returns:
- a
String
representation of the time
-
formatHTTPDate
public static java.lang.String formatHTTPDate(java.util.Date pTime)
Formats the time to a HTTP date, using the RFC 1123 format, as described in RFC 2616 (HTTP/1.1), sec. 3.3.- Parameters:
pTime
- the time- Returns:
- a
String
representation of the time
-
parseHTTPDate
public static long parseHTTPDate(java.lang.String pDate) throws java.lang.NumberFormatException
Parses a HTTP date string into along
representing milliseconds since January 1, 1970 GMT.Use this method with headers that contain dates, such as
If-Modified-Since
orLast-Modified
.The date string may be in either RFC 1123, RFC 850 or ANSI C asctime() format, as described in RFC 2616 (HTTP/1.1), sec. 3.3
- Parameters:
pDate
- the date to parse- Returns:
- a
long
value representing the date, expressed as the number of milliseconds since January 1, 1970 GMT, - Throws:
java.lang.NumberFormatException
- if the date parameter is not parseable.java.lang.IllegalArgumentException
- if the date paramter isnull
-
parseHTTPDateImpl
private static java.util.Date parseHTTPDateImpl(java.lang.String pDate) throws java.lang.NumberFormatException
ParseHTTPDate implementation- Parameters:
pDate
- the date string to parse- Returns:
- a
Date
- Throws:
java.lang.NumberFormatException
- if the date parameter is not parseable.java.lang.IllegalArgumentException
- if the date paramter isnull
-
-