diff --git a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/client/HddsClientUtils.java b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/client/HddsClientUtils.java index a6813ebf60..9c590385a4 100644 --- a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/client/HddsClientUtils.java +++ b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/client/HddsClientUtils.java @@ -74,7 +74,7 @@ private HddsClientUtils() { */ public static String formatDateTime(long millis) { ZonedDateTime dateTime = ZonedDateTime.ofInstant( - Instant.ofEpochSecond(millis), DATE_FORMAT.get().getZone()); + Instant.ofEpochMilli(millis), DATE_FORMAT.get().getZone()); return DATE_FORMAT.get().format(dateTime); } @@ -85,7 +85,7 @@ public static String formatDateTime(long millis) { public static long formatDateTime(String date) throws ParseException { Preconditions.checkNotNull(date, "Date string should not be null."); return ZonedDateTime.parse(date, DATE_FORMAT.get()) - .toInstant().getEpochSecond(); + .toInstant().toEpochMilli(); } diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java index d21e5c588b..5cf869eee2 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java @@ -250,8 +250,8 @@ public OpenKeySession openKey(OmKeyArgs args) throws IOException { .setKeyName(args.getKeyName()) .setOmKeyLocationInfos(Collections.singletonList( new OmKeyLocationInfoGroup(0, locations))) - .setCreationTime(currentTime) - .setModificationTime(currentTime) + .setCreationTime(Time.now()) + .setModificationTime(Time.now()) .setDataSize(size) .setReplicationType(type) .setReplicationFactor(factor)