yihua commented on code in PR #13711:
URL: https://github.com/apache/hudi/pull/13711#discussion_r2359610528


##########
hudi-common/src/main/java/org/apache/hudi/common/util/DateTimeUtils.java:
##########
@@ -71,6 +77,41 @@ public static long instantToMicros(Instant instant) {
     }
   }
 
+  public static long instantToNanos(Instant instant) {
+    long seconds = instant.getEpochSecond();
+    int nanos = instant.getNano();
+
+    if (seconds < 0 && nanos > 0) {
+      // Shift seconds by +1, then subtract a full second in nanos
+      long totalNanos = Math.multiplyExact(seconds + 1, 1_000_000_000L);
+      long adjustment = nanos - 1_000_000_000L;
+      return Math.addExact(totalNanos, adjustment);
+    } else {
+      long totalNanos = Math.multiplyExact(seconds, 1_000_000_000L);
+      return Math.addExact(totalNanos, nanos);
+    }
+  }

Review Comment:
   Got it.  Add a code comment on the copying/adaptation?



-- 
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