nastra commented on code in PR #9008: URL: https://github.com/apache/iceberg/pull/9008#discussion_r1668555332
########## api/src/test/java/org/apache/iceberg/util/TestDateTimeUtil.java: ########## @@ -35,4 +36,36 @@ public void formatTimestampMillis() { assertThat(DateTimeUtil.formatTimestampMillis(1000000L)).isEqualTo(timestamp); assertThat(ZonedDateTime.parse(timestamp).toInstant().toEpochMilli()).isEqualTo(1000000L); } + + @Test + public void nanosToMicros() { + assertThat(DateTimeUtil.nanosToMicros(1510871468000001001L)).isEqualTo(1510871468000001L); + } + + @Test + public void isoTimestampToNanos() { + assertThat(DateTimeUtil.isoTimestampToNanos("2017-11-16T14:31:08.000001001-08:00")) + .isEqualTo(1510871468000001001L); + } + + @Test + public void convertNanos() { + assertThat(DateTimeUtil.convertNanos(1510871468000001001L, ChronoUnit.HOURS)).isEqualTo(419686); + assertThat(DateTimeUtil.convertNanos(1510871468000001001L, ChronoUnit.MINUTES)) + .isEqualTo(25181191); + assertThat(DateTimeUtil.convertNanos(1510871468000001001L, ChronoUnit.SECONDS)) + .isEqualTo(1510871468); + assertThat(DateTimeUtil.convertNanos(1510871468000001001L, ChronoUnit.MILLIS)) + .isEqualTo(1510871468000L); + assertThat(DateTimeUtil.convertNanos(1510871468000001001L, ChronoUnit.MICROS)) + .isEqualTo(1510871468000001L); + assertThat(DateTimeUtil.convertNanos(1510871468000001001L, ChronoUnit.NANOS)) + .isEqualTo(1510871468000001001L); + } + + @Test + public void convertNanosNegative() { + assertThat(DateTimeUtil.convertNanos(-1510871468000001001L, ChronoUnit.MILLIS)) Review Comment: this should also convert to MICROS and NANOS (similar to how `convertNanos()` is testing it) -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org