parent
0f71da5be6
commit
b0675c031e
|
|
@ -492,9 +492,14 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
return getFirst(PRAGMA);
|
return getFirst(PRAGMA);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Utility methods
|
// Date methods
|
||||||
|
|
||||||
private long getFirstDate(String headerName) {
|
/**
|
||||||
|
* Parse the first header value for the given header name as a date, return -1 if
|
||||||
|
* there is no value, or raise {@link IllegalArgumentException} if the value cannot be
|
||||||
|
* parsed as a date.
|
||||||
|
*/
|
||||||
|
public long getFirstDate(String headerName) {
|
||||||
String headerValue = getFirst(headerName);
|
String headerValue = getFirst(headerName);
|
||||||
if (headerValue == null) {
|
if (headerValue == null) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -513,7 +518,12 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
"\" for \"" + headerName + "\" header");
|
"\" for \"" + headerName + "\" header");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDate(String headerName, long date) {
|
/**
|
||||||
|
* Set the given date under the given header name after formatting it as a string
|
||||||
|
* using the pattern {@code "EEE, dd MMM yyyy HH:mm:ss zzz"}. The equivalent of
|
||||||
|
* {@link #set(String, String)} but for date headers.
|
||||||
|
*/
|
||||||
|
public void setDate(String headerName, long date) {
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMATS[0], Locale.US);
|
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMATS[0], Locale.US);
|
||||||
dateFormat.setTimeZone(GMT);
|
dateFormat.setTimeZone(GMT);
|
||||||
set(headerName, dateFormat.format(new Date(date)));
|
set(headerName, dateFormat.format(new Date(date)));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue