Package org.apache.nutch.net.protocols
Class HttpDateFormat
- java.lang.Object
-
- org.apache.nutch.net.protocols.HttpDateFormat
-
public class HttpDateFormat extends Object
Parse and format HTTP dates in HTTP headers, e.g., used to fill the "If-Modified-Since" request header field. HTTP dates use Greenwich Mean Time (GMT) as time zone and a date format like:Sun, 06 Nov 1994 08:49:37 GMT
See sec. 3.3.1 in RFC 2616 and sec. 7.1.1.1 in RFC 7231.
-
-
Field Summary
Fields Modifier and Type Field Description static DateTimeFormatter
FORMAT
static DateTimeFormatter
PARSE_FORMAT
Use a less restrictive format for parsing: accept single-digit day-of-month and any timezone
-
Constructor Summary
Constructors Constructor Description HttpDateFormat()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
main(String[] args)
static Date
toDate(String dateString)
static long
toLong(String dateString)
static String
toString(long millis)
static String
toString(Calendar cal)
static String
toString(Date date)
Get the HTTP format of the specified date.static ZonedDateTime
toZonedDateTime(String dateString)
-
-
-
Field Detail
-
FORMAT
public static final DateTimeFormatter FORMAT
-
PARSE_FORMAT
public static final DateTimeFormatter PARSE_FORMAT
Use a less restrictive format for parsing: accept single-digit day-of-month and any timezone
-
-
Method Detail
-
toString
public static String toString(Date date)
Get the HTTP format of the specified date.- Parameters:
date
- aDate
for conversion- Returns:
- the String HTTP representation of the date
-
toString
public static String toString(long millis)
-
toZonedDateTime
public static ZonedDateTime toZonedDateTime(String dateString) throws ParseException
- Throws:
ParseException
-
toDate
public static Date toDate(String dateString) throws ParseException
- Throws:
ParseException
-
toLong
public static long toLong(String dateString) throws ParseException
- Throws:
ParseException
-
-