@@ -1148,6 +1148,7 @@ public void setLastModified(long lastModified) {
1148
1148
/**
1149
1149
* Set the time the resource was last changed, as specified by the
1150
1150
* {@code Last-Modified} header.
1151
+ * @since 5.1.4
1151
1152
*/
1152
1153
public void setLastModified (Instant lastModified ) {
1153
1154
setInstant (LAST_MODIFIED , lastModified );
@@ -1156,9 +1157,10 @@ public void setLastModified(Instant lastModified) {
1156
1157
/**
1157
1158
* Set the time the resource was last changed, as specified by the
1158
1159
* {@code Last-Modified} header.
1160
+ * @since 5.1.4
1159
1161
*/
1160
1162
public void setLastModified (ZonedDateTime lastModified ) {
1161
- setZonedDateTime (LAST_MODIFIED , lastModified );
1163
+ setZonedDateTime (LAST_MODIFIED , lastModified . withZoneSameInstant ( ZoneId . of ( "GMT" )) );
1162
1164
}
1163
1165
1164
1166
/**
@@ -1276,19 +1278,20 @@ public List<String> getVary() {
1276
1278
* Set the given date under the given header name after formatting it as a string
1277
1279
* using the RFC-1123 date-time formatter. The equivalent of
1278
1280
* {@link #set(String, String)} but for date headers.
1279
- * @since 5.0
1281
+ * @since 5.1.4
1280
1282
*/
1281
- public void setZonedDateTime (String headerName , ZonedDateTime date ) {
1282
- set (headerName , DATE_FORMATTERS [ 0 ]. format (date ));
1283
+ public void setInstant (String headerName , Instant date ) {
1284
+ setZonedDateTime (headerName , ZonedDateTime . ofInstant (date , GMT ));
1283
1285
}
1284
1286
1285
1287
/**
1286
1288
* Set the given date under the given header name after formatting it as a string
1287
1289
* using the RFC-1123 date-time formatter. The equivalent of
1288
1290
* {@link #set(String, String)} but for date headers.
1291
+ * @since 5.0
1289
1292
*/
1290
- public void setInstant (String headerName , Instant date ) {
1291
- setZonedDateTime (headerName , ZonedDateTime . ofInstant (date , GMT ));
1293
+ public void setZonedDateTime (String headerName , ZonedDateTime date ) {
1294
+ set (headerName , DATE_FORMATTERS [ 0 ]. format (date ));
1292
1295
}
1293
1296
1294
1297
/**
@@ -1299,14 +1302,7 @@ public void setInstant(String headerName, Instant date) {
1299
1302
* @see #setZonedDateTime(String, ZonedDateTime)
1300
1303
*/
1301
1304
public void setDate (String headerName , long date ) {
1302
- set (headerName , formatDate (date ));
1303
- }
1304
-
1305
- // Package private: also used in ResponseCookie..
1306
- static String formatDate (long date ) {
1307
- Instant instant = Instant .ofEpochMilli (date );
1308
- ZonedDateTime time = ZonedDateTime .ofInstant (instant , GMT );
1309
- return DATE_FORMATTERS [0 ].format (time );
1305
+ setInstant (headerName , Instant .ofEpochMilli (date ));
1310
1306
}
1311
1307
1312
1308
/**
@@ -1656,4 +1652,11 @@ public static HttpHeaders writableHttpHeaders(HttpHeaders headers) {
1656
1652
}
1657
1653
}
1658
1654
1655
+ // Package-private: used in ResponseCookie
1656
+ static String formatDate (long date ) {
1657
+ Instant instant = Instant .ofEpochMilli (date );
1658
+ ZonedDateTime time = ZonedDateTime .ofInstant (instant , GMT );
1659
+ return DATE_FORMATTERS [0 ].format (time );
1660
+ }
1661
+
1659
1662
}
0 commit comments