Package org.eclipse.jetty.http
Class HttpDateTime
java.lang.Object
org.eclipse.jetty.http.HttpDateTime
HTTP Date/Time parsing and formatting.
Supports the following Date/Time formats found in both RFC 9110 (HTTP Semantics) and RFC 6265 (HTTP State Management Mechanism)
Sun, 06 Nov 1994 08:49:37 GMT
- RFC 1123 (preferred)Sunday, 06-Nov-94 08:49:37 GMT
- RFC 850 (obsolete)Sun Nov 6 08:49:37 1994
- ANSI C'sasctime()
format (obsolete)
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
format
(TemporalAccessor datetime) Formats provided Date/Time to a String following preferred RFC 1123 syntax from both HTTP and Cookie specs.static ZonedDateTime
Parses a Date/Time valuestatic long
parseToEpoch
(String datetime) Similar toparse(String)
but returns unix epoch
-
Method Details
-
parseToEpoch
Similar toparse(String)
but returns unix epoch- Parameters:
datetime
- the Date/Time to parse.- Returns:
- unix epoch in milliseconds, or -1 if unable to parse the input date/time
-
parse
Parses a Date/Time value
Parsing is done according to the algorithm specified in RFC6265: Section 5.1.1: Date
- Parameters:
datetime
- a Date/Time string in a supported format- Returns:
- an
ZonedDateTime
parsed from the given string - Throws:
IllegalArgumentException
- if unable to parse date/time
-
format
Formats provided Date/Time to a String following preferred RFC 1123 syntax from both HTTP and Cookie specs.- Parameters:
datetime
- the date/time to format- Returns:
- the String representation of the date/time
-