Skip to content

Commit

Permalink
Made utcTz static and renamed to UTC_TIMEZONE (#2519)
Browse files Browse the repository at this point in the history
Signed-off-by: Sven Diedrichsen <sdiedrichsen@yahoo.de>
  • Loading branch information
svendiedrichsen committed May 27, 2022
1 parent c9c268f commit ab803c6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pgjdbc/src/main/java/org/postgresql/jdbc/TimestampUtils.java
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ab803c6

Please sign in to comment.