jduo commented on code in PR #36519:
URL: https://github.com/apache/arrow/pull/36519#discussion_r1346210424


##########
java/flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/utils/DateTimeUtils.java:
##########
@@ -36,21 +38,17 @@ private DateTimeUtils() {
   }
 
   /**
-   * Subtracts given Calendar's TimeZone offset from epoch milliseconds.
+   * Apply calendar timezone to epoch milliseconds.
    */
   public static long applyCalendarOffset(long milliseconds, Calendar calendar) 
{
     if (calendar == null) {
       calendar = Calendar.getInstance();
     }
-
-    final TimeZone tz = calendar.getTimeZone();
-    final TimeZone defaultTz = TimeZone.getDefault();
-
-    if (tz != defaultTz) {
-      milliseconds -= tz.getOffset(milliseconds) - 
defaultTz.getOffset(milliseconds);
-    }
-
-    return milliseconds;
+    Instant currInstant = Instant.ofEpochMilli(milliseconds);
+    LocalDateTime getTimestampWithoutTZ = LocalDateTime.ofInstant(currInstant,
+            TimeZone.getTimeZone("UTC").toZoneId());
+    ZonedDateTime parsedTime = 
getTimestampWithoutTZ.atZone(calendar.getTimeZone().toZoneId());
+    return parsedTime.toEpochSecond() * 1000;

Review Comment:
   parsedTime.toInstant().toEpochMilli() seems like it would avoid this problem.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to