You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2020/07/13 03:53:46 UTC

[GitHub] [commons-io] Isira-Seneviratne commented on a change in pull request #124: [IO-676] Add isFileNewer() and isFileOlder() methods that support the Java 8 Date/Time API.

Isira-Seneviratne commented on a change in pull request #124:
URL: https://github.com/apache/commons-io/pull/124#discussion_r453421126



##########
File path: src/main/java/org/apache/commons/io/FileUtils.java
##########
@@ -1624,6 +1631,119 @@ public static boolean isFileNewer(final File file, final long timeMillis) {
         return file.lastModified() > timeMillis;
     }
 
+    /**
+     * Tests if the specified <code>File</code> is newer than the specified
+     * <code>Instant</code>.
+     *
+     * @param file    the <code>File</code> of which the modification date
+     *                must be compared, must not be {@code null}
+     * @param instant the date reference, must not be {@code null}
+     * @return true if the <code>File</code> exists and has been modified
+     * after the given <code>Instant</code>.
+     * @throws IllegalArgumentException if the file or instant is {@code null}
+     */
+    public static boolean isFileNewer(final File file, final Instant instant) {
+        if (instant == null) {
+            throw new IllegalArgumentException("No specified instant");
+        }
+        return isFileNewer(file, instant.toEpochMilli());
+    }
+
+    /**
+     * Tests if the specified <code>File</code> is newer than the specified
+     * <code>ZonedDateTime</code>.
+     *
+     * @param file          the <code>File</code> of which the modification date
+     *                      must be compared, must not be {@code null}
+     * @param zonedDateTime the date reference, must not be {@code null}
+     * @return true if the <code>File</code> exists and has been modified
+     * after the given <code>ZonedDateTime</code>.
+     * @throws IllegalArgumentException if the file or zoned date time is {@code null}
+     */
+    public static boolean isFileNewer(final File file, final ZonedDateTime zonedDateTime) {

Review comment:
       The Javadoc for `ChronoZonedDateTime` includes this statement: "Most applications should declare method signatures, fields and variables as `ZonedDateTime`, not this interface."




----------------------------------------------------------------
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.

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