You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by bl...@apache.org on 2020/05/05 16:37:05 UTC
[incubator-iceberg] branch master updated: Add DateTimeUtil
conversions to internal values (#1003)
This is an automated email from the ASF dual-hosted git repository.
blue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iceberg.git
The following commit(s) were added to refs/heads/master by this push:
new ec654f9 Add DateTimeUtil conversions to internal values (#1003)
ec654f9 is described below
commit ec654f9502556e952a18e9a42ce9d64a50965bfe
Author: Xiang Li <wa...@gmail.com>
AuthorDate: Wed May 6 00:36:56 2020 +0800
Add DateTimeUtil conversions to internal values (#1003)
---
.../main/java/org/apache/iceberg/data/DateTimeUtil.java | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/data/src/main/java/org/apache/iceberg/data/DateTimeUtil.java b/data/src/main/java/org/apache/iceberg/data/DateTimeUtil.java
index d6ab178..7380b8c 100644
--- a/data/src/main/java/org/apache/iceberg/data/DateTimeUtil.java
+++ b/data/src/main/java/org/apache/iceberg/data/DateTimeUtil.java
@@ -38,15 +38,31 @@ public class DateTimeUtil {
return ChronoUnit.DAYS.addTo(EPOCH_DAY, daysFromEpoch);
}
+ public static int daysFromDate(LocalDate date) {
+ return (int) ChronoUnit.DAYS.between(EPOCH_DAY, date);
+ }
+
public static LocalTime timeFromMicros(long microFromMidnight) {
return LocalTime.ofNanoOfDay(microFromMidnight * 1000);
}
+ public static long microsFromTime(LocalTime time) {
+ return time.toNanoOfDay() / 1000;
+ }
+
public static LocalDateTime timestampFromMicros(long microsFromEpoch) {
return ChronoUnit.MICROS.addTo(EPOCH, microsFromEpoch).toLocalDateTime();
}
+ public static long microsFromTimestamp(LocalDateTime dateTime) {
+ return ChronoUnit.MICROS.between(EPOCH, dateTime.atOffset(ZoneOffset.UTC));
+ }
+
public static OffsetDateTime timestamptzFromMicros(long microsFromEpoch) {
return ChronoUnit.MICROS.addTo(EPOCH, microsFromEpoch);
}
+
+ public static long microsFromTimestamptz(OffsetDateTime dateTime) {
+ return ChronoUnit.MICROS.between(EPOCH, dateTime);
+ }
}