Make date methods in HttpHeaders public

Issue: SPR-10713
This commit is contained in:
Rossen Stoyanchev 2013-08-05 12:37:18 -04:00
parent 0f71da5be6
commit b0675c031e
1 changed files with 13 additions and 3 deletions

View File

@ -492,9 +492,14 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
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);
if (headerValue == null) {
return -1;
@ -513,7 +518,12 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
"\" 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);
dateFormat.setTimeZone(GMT);
set(headerName, dateFormat.format(new Date(date)));