You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2021/02/12 02:22:27 UTC

[GitHub] [hive] belugabehr commented on a change in pull request #1938: HIVE-24693: Convert timestamps to zoned times without string operations

belugabehr commented on a change in pull request #1938:
URL: https://github.com/apache/hive/pull/1938#discussion_r574954797



##########
File path: common/src/java/org/apache/hadoop/hive/common/type/TimestampTZUtil.java
##########
@@ -127,12 +127,15 @@ public static TimestampTZ parseOrNull(String s, ZoneId defaultTimeZone) {
 
   // Converts Date to TimestampTZ.
   public static TimestampTZ convert(Date date, ZoneId defaultTimeZone) {
-    return parse(date.toString(), defaultTimeZone);
+    return new TimestampTZ(ZonedDateTime.ofInstant(Instant.ofEpochMilli(date.toEpochMilli()), ZoneOffset.UTC)
+        .withZoneSameLocal(defaultTimeZone));
   }
 
   // Converts Timestamp to TimestampTZ.
   public static TimestampTZ convert(Timestamp ts, ZoneId defaultTimeZone) {
-    return parse(ts.toString(), defaultTimeZone);
+    return new TimestampTZ(
+        ZonedDateTime.ofInstant(Instant.ofEpochSecond(ts.toEpochSecond(), ts.getNanos()), ZoneOffset.UTC)

Review comment:
       Hey, what do you mean by same style? 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org