diff --git a/presto-hive/src/main/java/com/facebook/presto/hive/GenericHiveRecordCursor.java b/presto-hive/src/main/java/com/facebook/presto/hive/GenericHiveRecordCursor.java index 289492a1fc6c..830e0ba93644 100644 --- a/presto-hive/src/main/java/com/facebook/presto/hive/GenericHiveRecordCursor.java +++ b/presto-hive/src/main/java/com/facebook/presto/hive/GenericHiveRecordCursor.java @@ -86,6 +86,8 @@ class GenericHiveRecordCursor implements RecordCursor { + private static final DateTimeZone JVM_TIME_ZONE = DateTimeZone.getDefault(); + private final Path path; private final RecordReader recordReader; private final K key; @@ -293,7 +295,7 @@ private static long getLongExpressedValue(Object value, DateTimeZone hiveTimeZon if (value instanceof Date) { long storageTime = ((Date) value).getTime(); // convert date from VM current time zone to UTC - long utcMillis = storageTime + DateTimeZone.getDefault().getOffset(storageTime); + long utcMillis = storageTime + JVM_TIME_ZONE.getOffset(storageTime); return TimeUnit.MILLISECONDS.toDays(utcMillis); } if (value instanceof Timestamp) { @@ -305,13 +307,10 @@ private static long getLongExpressedValue(Object value, DateTimeZone hiveTimeZon long parsedJvmMillis = ((Timestamp) value).getTime(); // remove the JVM time zone correction from the timestamp - DateTimeZone jvmTimeZone = DateTimeZone.getDefault(); - long hiveMillis = jvmTimeZone.convertUTCToLocal(parsedJvmMillis); + long hiveMillis = JVM_TIME_ZONE.convertUTCToLocal(parsedJvmMillis); // convert to UTC using the real time zone for the underlying data - long utcMillis = hiveTimeZone.convertLocalToUTC(hiveMillis, false); - - return utcMillis; + return hiveTimeZone.convertLocalToUTC(hiveMillis, false); } if (value instanceof Float) { return floatToRawIntBits(((Float) value));