From ab803c671cf67aa1452431c669636855451eca3b Mon Sep 17 00:00:00 2001 From: Sven Diedrichsen Date: Fri, 27 May 2022 16:02:04 +0200 Subject: [PATCH] Made utcTz static and renamed to UTC_TIMEZONE (#2519) Signed-off-by: Sven Diedrichsen --- pgjdbc/src/main/java/org/postgresql/jdbc/TimestampUtils.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pgjdbc/src/main/java/org/postgresql/jdbc/TimestampUtils.java b/pgjdbc/src/main/java/org/postgresql/jdbc/TimestampUtils.java index 62c6993f66..0e5d9fbdb7 100644 --- a/pgjdbc/src/main/java/org/postgresql/jdbc/TimestampUtils.java +++ b/pgjdbc/src/main/java/org/postgresql/jdbc/TimestampUtils.java @@ -70,6 +70,8 @@ public class TimestampUtils { private static final @Nullable Field DEFAULT_TIME_ZONE_FIELD; + private static final TimeZone UTC_TIMEZONE = TimeZone.getTimeZone(ZoneOffset.UTC); + private @Nullable TimeZone prevDefaultZoneFieldValue; private @Nullable TimeZone defaultTimeZoneCache; @@ -128,7 +130,6 @@ public class TimestampUtils { // This calendar is used when user provides calendar in setX(, Calendar) method. // It ensures calendar is Gregorian. private final Calendar calendarWithUserTz = new GregorianCalendar(); - private final TimeZone utcTz = TimeZone.getTimeZone(ZoneOffset.UTC); private @Nullable Calendar calCache; private @Nullable ZoneOffset calCacheZone; @@ -1381,7 +1382,7 @@ private long guessTimestamp(long millis, @Nullable TimeZone tz) { // Note: cal.setTimeZone alone is not sufficient as it would alter hour (it will try to keep the // same time instant value) Calendar cal = calendarWithUserTz; - cal.setTimeZone(utcTz); + cal.setTimeZone(UTC_TIMEZONE); cal.setTimeInMillis(millis); int era = cal.get(Calendar.ERA); int year = cal.get(Calendar.YEAR);