okumin commented on code in PR #5014: URL: https://github.com/apache/hive/pull/5014#discussion_r1484012893
########## ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFFromUtcTimestamp.java: ########## @@ -88,31 +88,42 @@ public Object evaluate(DeferredObject[] arguments) throws HiveException { Timestamp inputTs = ((TimestampWritableV2) converted_o0).getTimestamp(); String tzStr = textConverter.convert(o1).toString(); - TimeZone timezone = TimeZone.getTimeZone(tzStr); - - TimeZone fromTz; - TimeZone toTz; - if (invert()) { - fromTz = timezone; - toTz = tzUTC; - } else { - fromTz = tzUTC; - toTz = timezone; - } - // inputTs is the year/month/day/hour/minute/second in the local timezone. - // For this UDF we want it in the timezone represented by fromTz - TimestampTZ fromTs = TimestampTZUtil.parse(inputTs.toString(), fromTz.toZoneId()); + ZoneId zoneId; + try{ Review Comment: We may prefer to have a space before/after a parenthesis. ########## ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFFromUtcTimestamp.java: ########## @@ -88,31 +88,42 @@ public Object evaluate(DeferredObject[] arguments) throws HiveException { Timestamp inputTs = ((TimestampWritableV2) converted_o0).getTimestamp(); String tzStr = textConverter.convert(o1).toString(); - TimeZone timezone = TimeZone.getTimeZone(tzStr); - - TimeZone fromTz; - TimeZone toTz; - if (invert()) { - fromTz = timezone; - toTz = tzUTC; - } else { - fromTz = tzUTC; - toTz = timezone; - } - // inputTs is the year/month/day/hour/minute/second in the local timezone. - // For this UDF we want it in the timezone represented by fromTz - TimestampTZ fromTs = TimestampTZUtil.parse(inputTs.toString(), fromTz.toZoneId()); + ZoneId zoneId; + try{ + zoneId = ZoneId.of(tzStr); Review Comment: `ZoneID.of(tzStr, ZoneId.SHORT_IDS` could be shorthand. If no, please ignore this comment. https://docs.oracle.com/javase/8/docs/api/java/time/ZoneId.html#of-java.lang.String-java.util.Map- ########## ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFFromUtcTimestamp.java: ########## @@ -88,31 +88,42 @@ public Object evaluate(DeferredObject[] arguments) throws HiveException { Timestamp inputTs = ((TimestampWritableV2) converted_o0).getTimestamp(); String tzStr = textConverter.convert(o1).toString(); - TimeZone timezone = TimeZone.getTimeZone(tzStr); - - TimeZone fromTz; - TimeZone toTz; - if (invert()) { - fromTz = timezone; - toTz = tzUTC; - } else { - fromTz = tzUTC; - toTz = timezone; - } - // inputTs is the year/month/day/hour/minute/second in the local timezone. - // For this UDF we want it in the timezone represented by fromTz - TimestampTZ fromTs = TimestampTZUtil.parse(inputTs.toString(), fromTz.toZoneId()); + ZoneId zoneId; + try{ + zoneId = ZoneId.of(tzStr); + }catch (Exception exception) { Review Comment: We may prefer to have a space before/after a parenthesis. ########## ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFFromUtcTimestamp.java: ########## @@ -88,31 +88,42 @@ public Object evaluate(DeferredObject[] arguments) throws HiveException { Timestamp inputTs = ((TimestampWritableV2) converted_o0).getTimestamp(); String tzStr = textConverter.convert(o1).toString(); - TimeZone timezone = TimeZone.getTimeZone(tzStr); - - TimeZone fromTz; - TimeZone toTz; - if (invert()) { - fromTz = timezone; - toTz = tzUTC; - } else { - fromTz = tzUTC; - toTz = timezone; - } - // inputTs is the year/month/day/hour/minute/second in the local timezone. - // For this UDF we want it in the timezone represented by fromTz - TimestampTZ fromTs = TimestampTZUtil.parse(inputTs.toString(), fromTz.toZoneId()); + ZoneId zoneId; + try{ + zoneId = ZoneId.of(tzStr); + }catch (Exception exception) { + String timeZoneId = ZoneId.SHORT_IDS.get(tzStr); + if(timeZoneId == null){ Review Comment: We may prefer to have a space before/after a parenthesis. -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org