You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2020/09/23 13:16:33 UTC

[commons-io] 02/02: IO-689: FileUtils: Remove Instant->ZonedDateTime->Instant round-trip

This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git

commit e1a5fdde3937f47a8f78d14dff4f2c91337c2ad0
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Sep 23 14:16:25 2020 +0100

    IO-689: FileUtils: Remove Instant->ZonedDateTime->Instant round-trip
    
    This to/from round-trip conversion has no effect on the value of the
    Instant.
---
 src/changes/changes.xml                            | 3 +++
 src/main/java/org/apache/commons/io/FileUtils.java | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index adf5062..8f43539 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -59,6 +59,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="update" due-to="Gary Gregory">
         Update commons.jacoco.version 0.8.5 to 0.8.6 (Fixes Java 15 builds).
       </action>
+      <action issue="IO-689" dev="aherbert" type="fix" due-to="Uwe Schindler">
+        FileUtils: Remove Instant->ZonedDateTime->Instant round-trip.
+      </action>
     </release>
     <!-- The release date is the date RC is cut -->
     <release version="2.8.0" date="2020-09-05" description="Java 8 required.">
diff --git a/src/main/java/org/apache/commons/io/FileUtils.java b/src/main/java/org/apache/commons/io/FileUtils.java
index 3721358..25177d9 100644
--- a/src/main/java/org/apache/commons/io/FileUtils.java
+++ b/src/main/java/org/apache/commons/io/FileUtils.java
@@ -1787,7 +1787,7 @@ public class FileUtils {
      */
     public static boolean isFileNewer(final File file, final Instant instant) {
         Objects.requireNonNull(instant, "instant");
-        return isFileNewer(file, instant.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
+        return isFileNewer(file, instant.toEpochMilli());
     }
 
     /**
@@ -1955,7 +1955,7 @@ public class FileUtils {
      */
     public static boolean isFileOlder(final File file, final Instant instant) {
         Objects.requireNonNull(instant, "instant");
-        return isFileOlder(file, instant.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
+        return isFileOlder(file, instant.toEpochMilli());
     }
 
     /**