diff --git a/spring-test/src/main/java/org/springframework/test/http/HttpHeadersAssert.java b/spring-test/src/main/java/org/springframework/test/http/HttpHeadersAssert.java index af2fc3fed9c..3c41f4d9447 100644 --- a/spring-test/src/main/java/org/springframework/test/http/HttpHeadersAssert.java +++ b/spring-test/src/main/java/org/springframework/test/http/HttpHeadersAssert.java @@ -17,9 +17,7 @@ package org.springframework.test.http; import java.time.Instant; -import java.time.ZoneId; import java.time.ZoneOffset; -import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; import java.util.Arrays; import java.util.Collection; @@ -43,9 +41,6 @@ import org.springframework.http.HttpHeaders; */ public class HttpHeadersAssert extends AbstractObjectAssert { - private static final ZoneId GMT = ZoneOffset.UTC; - - private final AbstractCollectionAssert, String, ObjectAssert> namesAssert; @@ -174,7 +169,7 @@ public class HttpHeadersAssert extends AbstractObjectAssert stringHttpMessageConverter = mock(); @@ -477,7 +473,7 @@ class HttpEntityMethodProcessorMockTests { void shouldHandleLastModifiedWithHttp304() throws Exception { long currentTime = new Date().getTime(); long oneMinuteAgo = currentTime - (1000 * 60); - ZonedDateTime dateTime = ofEpochMilli(currentTime).atZone(GMT); + ZonedDateTime dateTime = ofEpochMilli(currentTime).atZone(ZoneOffset.UTC); servletRequest.addHeader(HttpHeaders.IF_MODIFIED_SINCE, RFC_1123_DATE_TIME.format(dateTime)); ResponseEntity returnValue = ResponseEntity.ok().lastModified(oneMinuteAgo).body("body"); @@ -537,7 +533,7 @@ class HttpEntityMethodProcessorMockTests { long currentTime = new Date().getTime(); long oneMinuteAgo = currentTime - (1000 * 60); String etagValue = "\"deadb33f8badf00d\""; - ZonedDateTime dateTime = ofEpochMilli(currentTime).atZone(GMT); + ZonedDateTime dateTime = ofEpochMilli(currentTime).atZone(ZoneOffset.UTC); servletRequest.addHeader(HttpHeaders.IF_MODIFIED_SINCE, RFC_1123_DATE_TIME.format(dateTime)); servletRequest.addHeader(HttpHeaders.IF_NONE_MATCH, etagValue); ResponseEntity returnValue = ResponseEntity.ok() @@ -569,7 +565,7 @@ class HttpEntityMethodProcessorMockTests { long oneMinuteAgo = currentTime - (1000 * 60); String etagValue = "\"deadb33f8badf00d\""; String changedEtagValue = "\"changed-etag-value\""; - ZonedDateTime dateTime = ofEpochMilli(currentTime).atZone(GMT); + ZonedDateTime dateTime = ofEpochMilli(currentTime).atZone(ZoneOffset.UTC); servletRequest.addHeader(HttpHeaders.IF_MODIFIED_SINCE, RFC_1123_DATE_TIME.format(dateTime)); servletRequest.addHeader(HttpHeaders.IF_NONE_MATCH, etagValue); ResponseEntity returnValue = ResponseEntity.ok() @@ -625,7 +621,7 @@ class HttpEntityMethodProcessorMockTests { void shouldHandleIfNoneMatchIfUnmodifiedSince() throws Exception { String etagValue = "\"some-etag\""; servletRequest.addHeader(HttpHeaders.IF_NONE_MATCH, etagValue); - ZonedDateTime dateTime = ofEpochMilli(new Date().getTime()).atZone(GMT); + ZonedDateTime dateTime = ofEpochMilli(new Date().getTime()).atZone(ZoneOffset.UTC); servletRequest.addHeader(HttpHeaders.IF_UNMODIFIED_SINCE, RFC_1123_DATE_TIME.format(dateTime)); ResponseEntity returnValue = ResponseEntity.ok().eTag(etagValue).body("body"); @@ -732,7 +728,7 @@ class HttpEntityMethodProcessorMockTests { @Test void shouldNotFailPreconditionForPutRequests() throws Exception { servletRequest.setMethod("PUT"); - ZonedDateTime dateTime = ofEpochMilli(new Date().getTime()).atZone(GMT); + ZonedDateTime dateTime = ofEpochMilli(new Date().getTime()).atZone(ZoneOffset.UTC); servletRequest.addHeader(HttpHeaders.IF_UNMODIFIED_SINCE, RFC_1123_DATE_TIME.format(dateTime)); long justModified = dateTime.plusSeconds(1).toEpochSecond() * 1000;