Modernize java.time API usages

See gh-35861
Signed-off-by: Vincent Potucek <vpotucek@me.com>
This commit is contained in:
Vincent Potucek
2025-11-25 14:42:05 +01:00
committed by Sébastien Deleuze
parent 3686b89ab5
commit 83bbf16e6c
14 changed files with 31 additions and 32 deletions
@@ -18,6 +18,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;
@@ -42,7 +43,7 @@ import org.springframework.http.HttpHeaders;
*/
public class HttpHeadersAssert extends AbstractObjectAssert<HttpHeadersAssert, HttpHeaders> {
private static final ZoneId GMT = ZoneId.of("GMT");
private static final ZoneId GMT = ZoneOffset.UTC;
private final AbstractCollectionAssert<?, Collection<? extends String>, String, ObjectAssert<String>> namesAssert;
@@ -173,7 +174,7 @@ public class HttpHeadersAssert extends AbstractObjectAssert<HttpHeadersAssert, H
containsHeader(name);
Assertions.assertThat(this.actual.getFirstZonedDateTime(name))
.as("check primary date value for HTTP header '%s'", name)
.isCloseTo(ZonedDateTime.ofInstant(value, GMT), Assertions.within(999, ChronoUnit.MILLIS));
.isCloseTo(value.atZone(GMT), Assertions.within(999, ChronoUnit.MILLIS));
return this.myself;
}