You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/09/23 07:55:00 UTC

[jira] [Work logged] (IO-676) Add isFileNewer() and isFileOlder() methods that support the Java 8 Date/Time API.

     [ https://issues.apache.org/jira/browse/IO-676?focusedWorklogId=489452&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-489452 ]

ASF GitHub Bot logged work on IO-676:
-------------------------------------

                Author: ASF GitHub Bot
            Created on: 23/Sep/20 07:54
            Start Date: 23/Sep/20 07:54
    Worklog Time Spent: 10m 
      Work Description: uschindler commented on a change in pull request #124:
URL: https://github.com/apache/commons-io/pull/124#discussion_r493273792



##########
File path: src/main/java/org/apache/commons/io/FileUtils.java
##########
@@ -1603,93 +1598,272 @@ public static boolean isFileNewer(final File file, final File reference) {
     }
 
     /**
-     * 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;
         }
         return file.lastModified() > timeMillis;
     }
 
     /**
-     * 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) {

Review comment:
       This is not true, an Instant never has a timezone. Unfortunately this method now goes on the forbiddenAPI list of Lucene because of this.
   Instant is by definition not related to any time zone. toEpochMillies returns a UNIX timestamp.




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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 489452)
    Time Spent: 5h 40m  (was: 5.5h)

> Add isFileNewer() and isFileOlder() methods that support the Java 8 Date/Time API.
> ----------------------------------------------------------------------------------
>
>                 Key: IO-676
>                 URL: https://issues.apache.org/jira/browse/IO-676
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>            Reporter: Isira Seneviratne
>            Priority: Major
>             Fix For: 2.8.0
>
>          Time Spent: 5h 40m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)