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:31 UTC

[commons-io] branch master updated (466231a -> e1a5fdd)

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

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


    from 466231a  Update commons.jacoco.version 0.8.5 to 0.8.6 (Fixes Java 15 builds).
     new 8f4ccfc  IO-689: FileUtils: Document use of ZoneId.systemDefault()
     new e1a5fdd  IO-689: FileUtils: Remove Instant->ZonedDateTime->Instant round-trip

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                            |  3 ++
 src/main/java/org/apache/commons/io/FileUtils.java | 40 ++++++++++++++++++++--
 2 files changed, 41 insertions(+), 2 deletions(-)


[commons-io] 01/02: IO-689: FileUtils: Document use of ZoneId.systemDefault()

Posted by ah...@apache.org.
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 8f4ccfc0819152b18490960b698ab3fc2573d824
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Wed Sep 23 14:12:18 2020 +0100

    IO-689: FileUtils: Document use of ZoneId.systemDefault()
---
 src/main/java/org/apache/commons/io/FileUtils.java | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/src/main/java/org/apache/commons/io/FileUtils.java b/src/main/java/org/apache/commons/io/FileUtils.java
index 67070e9..3721358 100644
--- a/src/main/java/org/apache/commons/io/FileUtils.java
+++ b/src/main/java/org/apache/commons/io/FileUtils.java
@@ -1644,6 +1644,12 @@ public class FileUtils {
      * Tests if the specified {@code File} is newer than the specified {@code ChronoLocalDate}
      * at the current time.
      *
+     * <p>Note: The input date is assumed to be in the system default time-zone with the time
+     * part set to the current time. To use a non-default time-zone use the method
+     * {@link #isFileNewer(File, ChronoLocalDateTime, ZoneId)
+     * isFileNewer(file, chronoLocalDate.atTime(LocalTime.now(zoneId)), zoneId)} where
+     * {@code zoneId} is a valid {@link ZoneId}.
+     *
      * @param file            the {@code File} of which the modification date must be compared
      * @param chronoLocalDate the date reference
      * @return true if the {@code File} exists and has been modified after the given
@@ -1660,6 +1666,11 @@ public class FileUtils {
      * Tests if the specified {@code File} is newer than the specified {@code ChronoLocalDate}
      * at the specified time.
      *
+     * <p>Note: The input date and time are assumed to be in the system default time-zone. To use a
+     * non-default time-zone use the method {@link #isFileNewer(File, ChronoLocalDateTime, ZoneId)
+     * isFileNewer(file, chronoLocalDate.atTime(localTime), zoneId)} where {@code zoneId} is a valid
+     * {@link ZoneId}.
+     *
      * @param file            the {@code File} of which the modification date must be compared
      * @param chronoLocalDate the date reference
      * @param localTime       the time reference
@@ -1679,6 +1690,11 @@ public class FileUtils {
      * Tests if the specified {@code File} is newer than the specified {@code ChronoLocalDateTime}
      * at the system-default time zone.
      *
+     * <p>Note: The input date and time is assumed to be in the system default time-zone. To use a
+     * non-default time-zone use the method {@link #isFileNewer(File, ChronoLocalDateTime, ZoneId)
+     * isFileNewer(file, chronoLocalDateTime, zoneId)} where {@code zoneId} is a valid
+     * {@link ZoneId}.
+     *
      * @param file                the {@code File} of which the modification date must be compared
      * @param chronoLocalDateTime the date reference
      * @return true if the {@code File} exists and has been modified after the given
@@ -1795,11 +1811,19 @@ public class FileUtils {
      * Tests if the specified {@code File} is older than the specified {@code ChronoLocalDate}
      * at the current time.
      *
+     * <p>Note: The input date is assumed to be in the system default time-zone with the time
+     * part set to the current time. To use a non-default time-zone use the method
+     * {@link #isFileOlder(File, ChronoLocalDateTime, ZoneId)
+     * isFileOlder(file, chronoLocalDate.atTime(LocalTime.now(zoneId)), zoneId)} where
+     * {@code zoneId} is a valid {@link ZoneId}.
+     *
      * @param file            the {@code File} of which the modification date must be compared
      * @param chronoLocalDate the date reference
      * @return true if the {@code File} exists and has been modified before the given
      * {@code ChronoLocalDate} at the current time.
      * @throws NullPointerException if the file or local date is {@code null}
+     * @see ZoneId#systemDefault()
+     * @see LocalTime#now()
      *
      * @since 2.8.0
      */
@@ -1811,12 +1835,18 @@ public class FileUtils {
      * Tests if the specified {@code File} is older than the specified {@code ChronoLocalDate}
      * at the specified {@code LocalTime}.
      *
+     * <p>Note: The input date and time are assumed to be in the system default time-zone. To use a
+     * non-default time-zone use the method {@link #isFileOlder(File, ChronoLocalDateTime, ZoneId)
+     * isFileOlder(file, chronoLocalDate.atTime(localTime), zoneId)} where {@code zoneId} is a valid
+     * {@link ZoneId}.
+     *
      * @param file            the {@code File} of which the modification date must be compared
      * @param chronoLocalDate the date reference
      * @param localTime       the time reference
      * @return true if the {@code File} exists and has been modified before the
      * given {@code ChronoLocalDate} at the specified time.
      * @throws NullPointerException if the file, local date or local time is {@code null}
+     * @see ZoneId#systemDefault()
      *
      * @since 2.8.0
      */
@@ -1830,11 +1860,17 @@ public class FileUtils {
      * Tests if the specified {@code File} is older than the specified {@code ChronoLocalDateTime}
      * at the system-default time zone.
      *
+     * <p>Note: The input date and time is assumed to be in the system default time-zone. To use a
+     * non-default time-zone use the method {@link #isFileOlder(File, ChronoLocalDateTime, ZoneId)
+     * isFileOlder(file, chronoLocalDateTime, zoneId)} where {@code zoneId} is a valid
+     * {@link ZoneId}.
+     *
      * @param file                the {@code File} of which the modification date must be compared
      * @param chronoLocalDateTime the date reference
      * @return true if the {@code File} exists and has been modified before the given
      * {@code ChronoLocalDateTime} at the system-default time zone.
      * @throws NullPointerException if the file or local date time is {@code null}
+     * @see ZoneId#systemDefault()
      *
      * @since 2.8.0
      */


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

Posted by ah...@apache.org.
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());
     }
 
     /**