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 DateTimeFormatterFORMATstatic DateTimeFormatterPARSE_FORMATUse 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 voidmain(String[] args)static DatetoDate(String dateString)static longtoLong(String dateString)static StringtoString(long millis)static StringtoString(Calendar cal)static StringtoString(Date date)Get the HTTP format of the specified date.static ZonedDateTimetoZonedDateTime(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- aDatefor 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
-
-