You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2021/10/26 17:25:55 UTC

[GitHub] [hudi] davehagman commented on a change in pull request #3824: [HUDI-1292] Millisecond granularity for instant timestamps

davehagman commented on a change in pull request #3824:
URL: https://github.com/apache/hudi/pull/3824#discussion_r736766669



##########
File path: hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieActiveTimeline.java
##########
@@ -74,6 +84,43 @@
   protected HoodieTableMetaClient metaClient;
   private static AtomicReference<String> lastInstantTime = new AtomicReference<>(String.valueOf(Integer.MIN_VALUE));
 
+  /**
+   * Parses the given instant ID to return a date instance.
+   * @param instant The instant ID
+   * @return A date
+   * @throws ParseException If the instant ID is malformed
+   */
+  public static Date parseDateFromInstantTime(String instant) throws ParseException {
+    // Enables backwards compatibility with non-millisecond granularity instants
+    if (isMillisecondGranularity(instant)) {
+      return COMMIT_FORMATTER.parse(instant);
+    } else {
+      // Add milliseconds to the instant in order to parse successfully
+      return COMMIT_FORMATTER.parse(instant + "000");

Review comment:
       Good catch. Fixed




-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org