mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-22 14:09:25 +00:00
Modernize java.time API usages
See gh-35861 Signed-off-by: Vincent Potucek <vpotucek@me.com>
This commit is contained in:
committed by
Sébastien Deleuze
parent
3686b89ab5
commit
83bbf16e6c
@@ -27,6 +27,7 @@ import java.text.DecimalFormatSymbols;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
@@ -414,7 +415,7 @@ public class HttpHeaders implements Serializable {
|
||||
|
||||
private static final DecimalFormatSymbols DECIMAL_FORMAT_SYMBOLS = new DecimalFormatSymbols(Locale.ROOT);
|
||||
|
||||
private static final ZoneId GMT = ZoneId.of("GMT");
|
||||
private static final ZoneId GMT = ZoneOffset.UTC;
|
||||
|
||||
/**
|
||||
* Date formats with time zone as specified in the HTTP RFC to use for formatting.
|
||||
@@ -1516,7 +1517,7 @@ public class HttpHeaders implements Serializable {
|
||||
* @since 5.1.4
|
||||
*/
|
||||
public void setInstant(String headerName, Instant date) {
|
||||
setZonedDateTime(headerName, ZonedDateTime.ofInstant(date, GMT));
|
||||
setZonedDateTime(headerName, date.atZone(GMT));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2172,7 +2173,7 @@ public class HttpHeaders implements Serializable {
|
||||
// Package-private: used in ResponseCookie
|
||||
static String formatDate(long date) {
|
||||
Instant instant = Instant.ofEpochMilli(date);
|
||||
ZonedDateTime time = ZonedDateTime.ofInstant(instant, GMT);
|
||||
ZonedDateTime time = instant.atZone(GMT);
|
||||
return DATE_FORMATTER.format(time);
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -19,7 +19,6 @@ package org.springframework.web.server.session;
|
||||
import java.time.Clock;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
@@ -51,7 +50,7 @@ public class InMemoryWebSessionStore implements WebSessionStore {
|
||||
|
||||
private int maxSessions = 10000;
|
||||
|
||||
private Clock clock = Clock.system(ZoneId.of("GMT"));
|
||||
private Clock clock = Clock.systemUTC();
|
||||
|
||||
private final Map<String, InMemoryWebSession> sessions = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user