Skip to content

Commit cb77440

Browse files
committed
Make date methods in HttpHeaders public
Issue: SPR-10713
1 parent 9245fff commit cb77440

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

spring-web/src/main/java/org/springframework/http/HttpHeaders.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -677,9 +677,14 @@ public String getUpgrade() {
677677
return getFirst(UPGARDE);
678678
}
679679

680-
// Utility methods
680+
// Date methods
681681

682-
private long getFirstDate(String headerName) {
682+
/**
683+
* Parse the first header value for the given header name as a date, return -1 if
684+
* there is no value, or raise {@link IllegalArgumentException} if the value cannot be
685+
* parsed as a date.
686+
*/
687+
public long getFirstDate(String headerName) {
683688
String headerValue = getFirst(headerName);
684689
if (headerValue == null) {
685690
return -1;
@@ -698,7 +703,12 @@ private long getFirstDate(String headerName) {
698703
"\" for \"" + headerName + "\" header");
699704
}
700705

701-
private void setDate(String headerName, long date) {
706+
/**
707+
* Set the given date under the given header name after formatting it as a string
708+
* using the pattern {@code "EEE, dd MMM yyyy HH:mm:ss zzz"}. The equivalent of
709+
* {@link #set(String, String)} but for date headers.
710+
*/
711+
public void setDate(String headerName, long date) {
702712
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMATS[0], Locale.US);
703713
dateFormat.setTimeZone(GMT);
704714
set(headerName, dateFormat.format(new Date(date)));

0 commit comments

Comments
 (0)