You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/08/28 22:00:45 UTC

[commons-io] branch master updated: [IO-676] Add isFileNewer() and isFileOlder() methods that support the Java 8 Date/Time API. (#124)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new c1fb4ae  [IO-676] Add isFileNewer() and isFileOlder() methods that support the Java 8 Date/Time API. (#124)
c1fb4ae is described below

commit c1fb4aebe215fbb46339f86ee80d6ed19699e7fe
Author: Isira Seneviratne <31...@users.noreply.github.com>
AuthorDate: Sat Aug 29 03:29:06 2020 +0530

    [IO-676] Add isFileNewer() and isFileOlder() methods that support the Java 8 Date/Time API. (#124)
    
    * Add isFileOlder methods that support the Java 8 Date/Time API.
    
    * Add isFileNewer methods that support the Java 8 Date/Time API.
    
    * Apply Javadoc comment changes suggested in PR comment.
    
    * Use Objects.requireNonNull() in the isFileNewer() and isFileOlder() methods.
    
    * Use ChronoLocalDate, ChronoLocalDateTime and ChronoZonedDateTime instead of LocalDate, LocalDateTime and ZonedDateTime to support other date/time formats such as JapaneseDate.
    
    * Add 'since' tags.
    
    * Set Instant to the current zone ID before doing the timestamp comparison.
---
 src/main/java/org/apache/commons/io/FileUtils.java | 318 ++++++++++++++++-----
 .../commons/io/FileUtilsFileNewerTestCase.java     |  12 +-
 .../org/apache/commons/io/FileUtilsTestCase.java   |  75 ++++-
 3 files changed, 313 insertions(+), 92 deletions(-)

diff --git a/src/main/java/org/apache/commons/io/FileUtils.java b/src/main/java/org/apache/commons/io/FileUtils.java
index 9c27372..488f64a 100644
--- a/src/main/java/org/apache/commons/io/FileUtils.java
+++ b/src/main/java/org/apache/commons/io/FileUtils.java
@@ -37,6 +37,12 @@ import java.nio.file.CopyOption;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.StandardCopyOption;
+import java.time.Instant;
+import java.time.LocalTime;
+import java.time.ZoneId;
+import java.time.chrono.ChronoLocalDate;
+import java.time.chrono.ChronoLocalDateTime;
+import java.time.chrono.ChronoZonedDateTime;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
@@ -83,7 +89,6 @@ import org.apache.commons.io.filefilter.TrueFileFilter;
  * </p>
  */
 public class FileUtils {
-
     /**
      * The number of bytes in a kilobyte.
      */
@@ -1661,42 +1666,32 @@ public class FileUtils {
     }
 
     /**
-     * Tests if the specified <code>File</code> is newer than the specified
-     * <code>Date</code>.
+     * Tests if the specified {@code File} is newer than the specified {@code Date}.
      *
-     * @param file the <code>File</code> of which the modification date
-     *             must be compared, must not be {@code null}
-     * @param date the date reference, must not be {@code null}
-     * @return true if the <code>File</code> exists and has been modified
-     * after the given <code>Date</code>.
-     * @throws IllegalArgumentException if the file is {@code null}
-     * @throws IllegalArgumentException if the date is {@code null}
+     * @param file the {@code File} of which the modification date must be compared
+     * @param date the date reference
+     * @return true if the {@code File} exists and has been modified
+     * after the given {@code Date}.
+     * @throws NullPointerException if the file or date is {@code null}
      */
     public static boolean isFileNewer(final File file, final Date date) {
-        if (date == null) {
-            throw new IllegalArgumentException("No specified date");
-        }
+        Objects.requireNonNull(date, "date");
         return isFileNewer(file, date.getTime());
     }
 
     //-----------------------------------------------------------------------
     /**
-     * Tests if the specified <code>File</code> is newer than the reference
-     * <code>File</code>.
+     * Tests if the specified {@code File} is newer than the reference {@code File}.
      *
-     * @param file      the <code>File</code> of which the modification date must
-     *                  be compared, must not be {@code null}
-     * @param reference the <code>File</code> of which the modification date
-     *                  is used, must not be {@code null}
-     * @return true if the <code>File</code> exists and has been modified more
-     * recently than the reference <code>File</code>
-     * @throws IllegalArgumentException if the file is {@code null}
-     * @throws IllegalArgumentException if the reference file is {@code null} or doesn't exist
+     * @param file      the {@code File} of which the modification date must be compared
+     * @param reference the {@code File} of which the modification date is used
+     * @return true if the {@code File} exists and has been modified more
+     * recently than the reference {@code File}
+     * @throws NullPointerException if the file or reference file is {@code null}
+     * @throws IllegalArgumentException if the reference file doesn't exist
      */
     public static boolean isFileNewer(final File file, final File reference) {
-        if (reference == null) {
-            throw new IllegalArgumentException("No specified reference file");
-        }
+        Objects.requireNonNull(reference, "reference");
         if (!reference.exists()) {
             throw new IllegalArgumentException("The reference file '"
                     + reference + "' doesn't exist");
@@ -1705,21 +1700,16 @@ public class FileUtils {
     }
 
     /**
-     * Tests if the specified <code>File</code> is newer than the specified
-     * time reference.
+     * Tests if the specified {@code File} is newer than the specified time reference.
      *
-     * @param file       the <code>File</code> of which the modification date must
-     *                   be compared, must not be {@code null}
+     * @param file       the {@code File} of which the modification date must be compared
      * @param timeMillis the time reference measured in milliseconds since the
      *                   epoch (00:00:00 GMT, January 1, 1970)
-     * @return true if the <code>File</code> exists and has been modified after
-     * the given time reference.
-     * @throws IllegalArgumentException if the file is {@code null}
+     * @return true if the {@code File} exists and has been modified after the given time reference.
+     * @throws NullPointerException if the file is {@code null}
      */
     public static boolean isFileNewer(final File file, final long timeMillis) {
-        if (file == null) {
-            throw new IllegalArgumentException("No specified file");
-        }
+        Objects.requireNonNull(file, "file");
         if (!file.exists()) {
             return false;
         }
@@ -1727,43 +1717,131 @@ public class FileUtils {
     }
 
     /**
-     * Tests if the specified <code>File</code> is older than the specified
-     * <code>Date</code>.
+     * Tests if the specified {@code File} is newer than the specified {@code Instant}.
+     *
+     * @param file    the {@code File} of which the modification date must be compared
+     * @param instant the date reference
+     * @return true if the {@code File} exists and has been modified after the given {@code Instant}.
+     * @throws NullPointerException if the file or instant is {@code null}
+     *
+     * @since 2.8
+     */
+    public static boolean isFileNewer(final File file, final Instant instant) {
+        Objects.requireNonNull(instant, "instant");
+        return isFileNewer(file, instant.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
+    }
+
+    /**
+     * Tests if the specified {@code File} is newer than the specified {@code ChronoZonedDateTime}.
+     *
+     * @param file                the {@code File} of which the modification date must be compared
+     * @param chronoZonedDateTime the date reference
+     * @return true if the {@code File} exists and has been modified after the given
+     * {@code ChronoZonedDateTime}.
+     * @throws NullPointerException if the file or zoned date time is {@code null}
+     *
+     * @since 2.8
+     */
+    public static boolean isFileNewer(final File file, final ChronoZonedDateTime<?> chronoZonedDateTime) {
+        Objects.requireNonNull(chronoZonedDateTime, "chronoZonedDateTime");
+        return isFileNewer(file, chronoZonedDateTime.toInstant());
+    }
+
+    /**
+     * Tests if the specified {@code File} is newer than the specified {@code ChronoLocalDateTime}
+     * at the system-default time zone.
+     *
+     * @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
+     * {@code ChronoLocalDateTime} at the system-default time zone.
+     * @throws NullPointerException if the file or local date time is {@code null}
+     *
+     * @since 2.8
+     */
+    public static boolean isFileNewer(final File file, final ChronoLocalDateTime<?> chronoLocalDateTime) {
+        return isFileNewer(file, chronoLocalDateTime, ZoneId.systemDefault());
+    }
+
+    /**
+     * Tests if the specified {@code File} is newer than the specified {@code ChronoLocalDateTime}
+     * at the specified {@code ZoneId}.
+     *
+     * @param file                the {@code File} of which the modification date must be compared
+     * @param chronoLocalDateTime the date reference
+     * @param zoneId              the time zone
+     * @return true if the {@code File} exists and has been modified after the given
+     * {@code ChronoLocalDateTime} at the given {@code ZoneId}.
+     * @throws NullPointerException if the file, local date time or zone ID is {@code null}
+     *
+     * @since 2.8
+     */
+    public static boolean isFileNewer(final File file, final ChronoLocalDateTime<?> chronoLocalDateTime, final ZoneId zoneId) {
+        Objects.requireNonNull(chronoLocalDateTime, "chronoLocalDateTime");
+        Objects.requireNonNull(zoneId, "zoneId");
+        return isFileNewer(file, chronoLocalDateTime.atZone(zoneId));
+    }
+
+    /**
+     * Tests if the specified {@code File} is newer than the specified {@code ChronoLocalDate}
+     * at the current time.
+     *
+     * @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
+     * {@code ChronoLocalDate} at the current time.
+     * @throws NullPointerException if the file or local date is {@code null}
+     *
+     * @since 2.8
+     */
+    public static boolean isFileNewer(final File file, final ChronoLocalDate chronoLocalDate) {
+        return isFileNewer(file, chronoLocalDate, LocalTime.now());
+    }
+
+    /**
+     * Tests if the specified {@code File} is newer than the specified {@code ChronoLocalDate}
+     * at the specified time.
+     *
+     * @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 after the given
+     * {@code ChronoLocalDate} at the given time.
+     * @throws NullPointerException if the file, local date or zone ID is {@code null}
+     *
+     * @since 2.8
+     */
+    public static boolean isFileNewer(final File file, final ChronoLocalDate chronoLocalDate, final LocalTime localTime) {
+        Objects.requireNonNull(chronoLocalDate, "chronoLocalDate");
+        Objects.requireNonNull(localTime, "localTime");
+        return isFileNewer(file, chronoLocalDate.atTime(localTime));
+    }
+
+    /**
+     * Tests if the specified {@code File} is older than the specified {@code Date}.
      *
-     * @param file the <code>File</code> of which the modification date
-     *             must be compared, must not be {@code null}
-     * @param date the date reference, must not be {@code null}
-     * @return true if the <code>File</code> exists and has been modified
-     * before the given <code>Date</code>.
-     * @throws IllegalArgumentException if the file is {@code null}
-     * @throws IllegalArgumentException if the date is {@code null}
+     * @param file the {@code File} of which the modification date must be compared
+     * @param date the date reference
+     * @return true if the {@code File} exists and has been modified before the given {@code Date}.
+     * @throws NullPointerException if the file or date is {@code null}
      */
     public static boolean isFileOlder(final File file, final Date date) {
-        if (date == null) {
-            throw new IllegalArgumentException("No specified date");
-        }
+        Objects.requireNonNull(date, "date");
         return isFileOlder(file, date.getTime());
     }
 
     //-----------------------------------------------------------------------
     /**
-     * Tests if the specified <code>File</code> is older than the reference
-     * <code>File</code>.
+     * Tests if the specified {@code File} is older than the reference {@code File}.
      *
-     * @param file      the <code>File</code> of which the modification date must
-     *                  be compared, must not be {@code null}
-     * @param reference the <code>File</code> of which the modification date
-     *                  is used, must not be {@code null}
-     * @return true if the <code>File</code> exists and has been modified before
-     * the reference <code>File</code>
-     * @throws IllegalArgumentException if the file is {@code null}
-     * @throws IllegalArgumentException if the reference file is {@code null} or doesn't exist
+     * @param file      the {@code File} of which the modification date must be compared
+     * @param reference the {@code File} of which the modification date is used
+     * @return true if the {@code File} exists and has been modified before the reference {@code File}
+     * @throws NullPointerException if the file or reference file is {@code null}
+     * @throws IllegalArgumentException if the reference file doesn't exist
      */
     public static boolean isFileOlder(final File file, final File reference) {
-        if (reference == null) {
-            throw new IllegalArgumentException("No specified reference file");
-        }
-        if (!reference.exists()) {
+        if (!Objects.requireNonNull(reference, "reference").exists()) {
             throw new IllegalArgumentException("The reference file '"
                     + reference + "' doesn't exist");
         }
@@ -1771,21 +1849,16 @@ public class FileUtils {
     }
 
     /**
-     * Tests if the specified <code>File</code> is older than the specified
-     * time reference.
+     * Tests if the specified {@code File} is older than the specified time reference.
      *
-     * @param file       the <code>File</code> of which the modification date must
-     *                   be compared, must not be {@code null}
+     * @param file       the {@code File} of which the modification date must be compared
      * @param timeMillis the time reference measured in milliseconds since the
      *                   epoch (00:00:00 GMT, January 1, 1970)
-     * @return true if the <code>File</code> exists and has been modified before
-     * the given time reference.
-     * @throws IllegalArgumentException if the file is {@code null}
+     * @return true if the {@code File} exists and has been modified before the given time reference.
+     * @throws NullPointerException if the file is {@code null}
      */
     public static boolean isFileOlder(final File file, final long timeMillis) {
-        if (file == null) {
-            throw new IllegalArgumentException("No specified file");
-        }
+        Objects.requireNonNull(file, "file");
         if (!file.exists()) {
             return false;
         }
@@ -1793,6 +1866,107 @@ public class FileUtils {
     }
 
     /**
+     * Tests if the specified {@code File} is older than the specified {@code Instant}.
+     *
+     * @param file    the {@code File} of which the modification date must be compared
+     * @param instant the date reference
+     * @return true if the {@code File} exists and has been modified before the given {@code Instant}.
+     * @throws NullPointerException if the file or instant is {@code null}
+     *
+     * @since 2.8
+     */
+    public static boolean isFileOlder(final File file, final Instant instant) {
+        Objects.requireNonNull(instant, "instant");
+        return isFileOlder(file, instant.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
+    }
+
+    /**
+     * Tests if the specified {@code File} is older than the specified {@code ChronoZonedDateTime}.
+     *
+     * @param file                the {@code File} of which the modification date must be compared
+     * @param chronoZonedDateTime the date reference
+     * @return true if the {@code File} exists and has been modified before the given
+     * {@code ChronoZonedDateTime}.
+     * @throws NullPointerException if the file or zoned date time is {@code null}
+     *
+     * @since 2.8
+     */
+    public static boolean isFileOlder(final File file, final ChronoZonedDateTime<?> chronoZonedDateTime) {
+        Objects.requireNonNull(chronoZonedDateTime, "chronoZonedDateTime");
+        return isFileOlder(file, chronoZonedDateTime.toInstant());
+    }
+
+    /**
+     * Tests if the specified {@code File} is older than the specified {@code ChronoLocalDateTime}
+     * at the system-default time zone.
+     *
+     * @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}
+     *
+     * @since 2.8
+     */
+    public static boolean isFileOlder(final File file, final ChronoLocalDateTime<?> chronoLocalDateTime) {
+        return isFileOlder(file, chronoLocalDateTime, ZoneId.systemDefault());
+    }
+
+    /**
+     * Tests if the specified {@code File} is older than the specified {@code ChronoLocalDateTime}
+     * at the specified {@code ZoneId}.
+     *
+     * @param file          the {@code File} of which the modification date must be compared
+     * @param chronoLocalDateTime the date reference
+     * @param zoneId        the time zone
+     * @return true if the {@code File} exists and has been modified before the given
+     * {@code ChronoLocalDateTime} at the given {@code ZoneId}.
+     * @throws NullPointerException if the file, local date time or zone ID is {@code null}
+     *
+     * @since 2.8
+     */
+    public static boolean isFileOlder(final File file, final ChronoLocalDateTime<?> chronoLocalDateTime, final ZoneId zoneId) {
+        Objects.requireNonNull(chronoLocalDateTime, "chronoLocalDateTime");
+        Objects.requireNonNull(zoneId, "zoneId");
+        return isFileOlder(file, chronoLocalDateTime.atZone(zoneId));
+    }
+
+    /**
+     * Tests if the specified {@code File} is older than the specified {@code ChronoLocalDate}
+     * at the current time.
+     *
+     * @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}
+     *
+     * @since 2.8
+     */
+    public static boolean isFileOlder(final File file, final ChronoLocalDate chronoLocalDate) {
+        return isFileOlder(file, chronoLocalDate, LocalTime.now());
+    }
+
+    /**
+     * Tests if the specified {@code File} is older than the specified {@code ChronoLocalDate}
+     * at the specified {@code LocalTime}.
+     *
+     * @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}
+     *
+     * @since 2.8
+     */
+    public static boolean isFileOlder(final File file, final ChronoLocalDate chronoLocalDate, final LocalTime localTime) {
+        Objects.requireNonNull(chronoLocalDate, "chronoLocalDate");
+        Objects.requireNonNull(localTime, "localTime");
+        return isFileOlder(file, chronoLocalDate.atTime(localTime));
+    }
+
+    /**
      * Determines whether the specified file is a Symbolic Link rather than an actual file.
      * <p>
      * Will not return true if there is a Symbolic Link anywhere in the path,
diff --git a/src/test/java/org/apache/commons/io/FileUtilsFileNewerTestCase.java b/src/test/java/org/apache/commons/io/FileUtilsFileNewerTestCase.java
index 370e06e..9020ca2 100644
--- a/src/test/java/org/apache/commons/io/FileUtilsFileNewerTestCase.java
+++ b/src/test/java/org/apache/commons/io/FileUtilsFileNewerTestCase.java
@@ -146,8 +146,8 @@ public class FileUtilsFileNewerTestCase {
      */
     @Test
     public void testIsFileNewerNoFile() {
-        assertThrows(IllegalArgumentException.class, () -> FileUtils.isFileNewer(null,0),
-                "File not specified");
+        assertThrows(NullPointerException.class, () -> FileUtils.isFileNewer(null,0),
+                "file");
     }
 
     /**
@@ -157,8 +157,8 @@ public class FileUtilsFileNewerTestCase {
      */
     @Test
     public void testIsFileNewerNoDate() {
-        assertThrows(IllegalArgumentException.class, () -> FileUtils.isFileNewer(m_testFile1, (Date) null),
-                "Date not specified");
+        assertThrows(NullPointerException.class, () -> FileUtils.isFileNewer(m_testFile1, (Date) null),
+                "date");
     }
 
     /**
@@ -168,7 +168,7 @@ public class FileUtilsFileNewerTestCase {
      */
     @Test
     public void testIsFileNewerNoFileReference() {
-        assertThrows(IllegalArgumentException.class, () -> FileUtils.isFileNewer(m_testFile1, (File) null),
-                "Reference file is not specified");
+        assertThrows(NullPointerException.class, () -> FileUtils.isFileNewer(m_testFile1, (File) null),
+                "reference");
     }
 }
diff --git a/src/test/java/org/apache/commons/io/FileUtilsTestCase.java b/src/test/java/org/apache/commons/io/FileUtilsTestCase.java
index b4aed65..0679320 100644
--- a/src/test/java/org/apache/commons/io/FileUtilsTestCase.java
+++ b/src/test/java/org/apache/commons/io/FileUtilsTestCase.java
@@ -39,6 +39,12 @@ import java.math.BigInteger;
 import java.net.URL;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -1024,6 +1030,12 @@ public class FileUtilsTestCase {
 
         final Date date = new Date();
         final long now = date.getTime();
+        final Instant instant = date.toInstant();
+        final ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(instant, ZoneId.systemDefault());
+        final LocalDateTime localDateTime = zonedDateTime.toLocalDateTime();
+        final LocalDate localDate = zonedDateTime.toLocalDate();
+        final LocalDate localDatePlusDay = localDate.plusDays(1);
+        final LocalTime localTime = LocalTime.ofSecondOfDay(0);
 
         do {
             try {
@@ -1048,9 +1060,26 @@ public class FileUtilsTestCase {
         assertFalse(FileUtils.isFileNewer(oldFile, reference), "Old File - Newer - File");
         assertFalse(FileUtils.isFileNewer(oldFile, date), "Old File - Newer - Date");
         assertFalse(FileUtils.isFileNewer(oldFile, now), "Old File - Newer - Mili");
+        assertFalse(FileUtils.isFileNewer(oldFile, instant), "Old File - Newer - Instant");
+        assertFalse(FileUtils.isFileNewer(oldFile, zonedDateTime), "Old File - Newer - ZonedDateTime");
+        assertFalse(FileUtils.isFileNewer(oldFile, localDateTime), "Old File - Newer - LocalDateTime");
+        assertFalse(FileUtils.isFileNewer(oldFile, localDateTime, ZoneId.systemDefault()), "Old File - Newer - LocalDateTime,ZoneId");
+        assertFalse(FileUtils.isFileNewer(oldFile, localDate), "Old File - Newer - LocalDate");
+        assertTrue(FileUtils.isFileNewer(oldFile, localDate, localTime), "Old File - Newer - LocalDate,ZoneId");
+        assertFalse(FileUtils.isFileNewer(oldFile, localDatePlusDay), "Old File - Newer - LocalDate plus one day");
+        assertFalse(FileUtils.isFileNewer(oldFile, localDatePlusDay, localTime), "Old File - Newer - LocalDate plus one day,ZoneId");
+
         assertTrue(FileUtils.isFileNewer(newFile, reference), "New File - Newer - File");
         assertTrue(FileUtils.isFileNewer(newFile, date), "New File - Newer - Date");
         assertTrue(FileUtils.isFileNewer(newFile, now), "New File - Newer - Mili");
+        assertTrue(FileUtils.isFileNewer(newFile, instant), "New File - Newer - Instant");
+        assertTrue(FileUtils.isFileNewer(newFile, zonedDateTime), "New File - Newer - ZonedDateTime");
+        assertTrue(FileUtils.isFileNewer(newFile, localDateTime), "New File - Newer - LocalDateTime");
+        assertTrue(FileUtils.isFileNewer(newFile, localDateTime, ZoneId.systemDefault()), "New File - Newer - LocalDateTime,ZoneId");
+        assertFalse(FileUtils.isFileNewer(newFile, localDate), "New File - Newer - LocalDate");
+        assertTrue(FileUtils.isFileNewer(newFile, localDate, localTime), "New File - Newer - LocalDate,ZoneId");
+        assertFalse(FileUtils.isFileNewer(newFile, localDatePlusDay), "New File - Newer - LocalDate plus one day");
+        assertFalse(FileUtils.isFileNewer(newFile, localDatePlusDay, localTime), "New File - Newer - LocalDate plus one day,ZoneId");
         assertFalse(FileUtils.isFileNewer(invalidFile, reference), "Invalid - Newer - File");
         final String invalidFileName = invalidFile.getName();
         try {
@@ -1065,9 +1094,27 @@ public class FileUtilsTestCase {
         assertTrue(FileUtils.isFileOlder(oldFile, reference), "Old File - Older - File");
         assertTrue(FileUtils.isFileOlder(oldFile, date), "Old File - Older - Date");
         assertTrue(FileUtils.isFileOlder(oldFile, now), "Old File - Older - Mili");
+        assertTrue(FileUtils.isFileOlder(oldFile, instant), "Old File - Older - Instant");
+        assertTrue(FileUtils.isFileOlder(oldFile, zonedDateTime), "Old File - Older - ZonedDateTime");
+        assertTrue(FileUtils.isFileOlder(oldFile, localDateTime), "Old File - Older - LocalDateTime");
+        assertTrue(FileUtils.isFileOlder(oldFile, localDateTime, ZoneId.systemDefault()), "Old File - Older - LocalDateTime,LocalTime");
+        assertTrue(FileUtils.isFileOlder(oldFile, localDate), "Old File - Older - LocalDate");
+        assertFalse(FileUtils.isFileOlder(oldFile, localDate, localTime), "Old File - Older - LocalDate,ZoneId");
+        assertTrue(FileUtils.isFileOlder(oldFile, localDatePlusDay), "Old File - Older - LocalDate plus one day");
+        assertTrue(FileUtils.isFileOlder(oldFile, localDatePlusDay, localTime), "Old File - Older - LocalDate plus one day,LocalTime");
+
         assertFalse(FileUtils.isFileOlder(newFile, reference), "New File - Older - File");
         assertFalse(FileUtils.isFileOlder(newFile, date), "New File - Older - Date");
         assertFalse(FileUtils.isFileOlder(newFile, now), "New File - Older - Mili");
+        assertFalse(FileUtils.isFileOlder(newFile, instant), "New File - Older - Instant");
+        assertFalse(FileUtils.isFileOlder(newFile, zonedDateTime), "New File - Older - ZonedDateTime");
+        assertFalse(FileUtils.isFileOlder(newFile, localDateTime), "New File - Older - LocalDateTime");
+        assertFalse(FileUtils.isFileOlder(newFile, localDateTime, ZoneId.systemDefault()), "New File - Older - LocalDateTime,ZoneId");
+        assertTrue(FileUtils.isFileOlder(newFile, localDate), "New File - Older - LocalDate");
+        assertFalse(FileUtils.isFileOlder(newFile, localDate, localTime), "New File - Older - LocalDate,LocalTime");
+        assertTrue(FileUtils.isFileOlder(newFile, localDatePlusDay), "New File - Older - LocalDate plus one day");
+        assertTrue(FileUtils.isFileOlder(newFile, localDatePlusDay, localTime), "New File - Older - LocalDate plus one day,LocalTime");
+
         assertFalse(FileUtils.isFileOlder(invalidFile, reference), "Invalid - Older - File");
         try {
             FileUtils.isFileOlder(newFile, invalidFile);
@@ -1082,23 +1129,23 @@ public class FileUtilsTestCase {
         // Null File
         try {
             FileUtils.isFileNewer(null, now);
-            fail("Newer Null, expected IllegalArgumentExcepion");
-        } catch (final IllegalArgumentException expected) {
+            fail("Newer Null, expected NullPointerException");
+        } catch (final NullPointerException expected) {
             // expected result
         }
 
         // Null reference File
         try {
             FileUtils.isFileNewer(oldFile, (File) null);
-            fail("Newer Null reference, expected IllegalArgumentExcepion");
-        } catch (final IllegalArgumentException ignore) {
+            fail("Newer Null reference, expected NullPointerException");
+        } catch (final NullPointerException ignore) {
             // expected result
         }
 
         // Invalid reference File
         try {
             FileUtils.isFileNewer(oldFile, invalidFile);
-            fail("Newer invalid reference, expected IllegalArgumentExcepion");
+            fail("Newer invalid reference, expected IllegalArgumentException");
         } catch (final IllegalArgumentException ignore) {
             // expected result
         }
@@ -1106,8 +1153,8 @@ public class FileUtilsTestCase {
         // Null reference Date
         try {
             FileUtils.isFileNewer(oldFile, (Date) null);
-            fail("Newer Null date, expected IllegalArgumentExcepion");
-        } catch (final IllegalArgumentException ignore) {
+            fail("Newer Null date, expected NullPointerException");
+        } catch (final NullPointerException ignore) {
             // expected result
         }
 
@@ -1116,23 +1163,23 @@ public class FileUtilsTestCase {
         // Null File
         try {
             FileUtils.isFileOlder(null, now);
-            fail("Older Null, expected IllegalArgumentExcepion");
-        } catch (final IllegalArgumentException ignore) {
+            fail("Older Null, expected NullPointerException");
+        } catch (final NullPointerException ignore) {
             // expected result
         }
 
         // Null reference File
         try {
             FileUtils.isFileOlder(oldFile, (File) null);
-            fail("Older Null reference, expected IllegalArgumentExcepion");
-        } catch (final IllegalArgumentException ignore) {
+            fail("Older Null reference, expected NullPointerException");
+        } catch (final NullPointerException ignore) {
             // expected result
         }
 
         // Invalid reference File
         try {
             FileUtils.isFileOlder(oldFile, invalidFile);
-            fail("Older invalid reference, expected IllegalArgumentExcepion");
+            fail("Older invalid reference, expected IllegalArgumentException");
         } catch (final IllegalArgumentException ignore) {
             // expected result
         }
@@ -1140,8 +1187,8 @@ public class FileUtilsTestCase {
         // Null reference Date
         try {
             FileUtils.isFileOlder(oldFile, (Date) null);
-            fail("Older Null date, expected IllegalArgumentExcepion");
-        } catch (final IllegalArgumentException ignore) {
+            fail("Older Null date, expected NullPointerException");
+        } catch (final NullPointerException ignore) {
             // expected result
         }