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

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

                Author: ASF GitHub Bot
            Created on: 23/Sep/20 07:59
            Start Date: 23/Sep/20 07:59
    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_r493278524



##########
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:
       The big risk of this forward/backward transformation is now that at the 
DST changes hour, the calculation is wrong: During DST change the same local 
date time exists 2 times. When you convert the instant to a local time (after 
local time went backwards due to DST change) and then you convert the local 
time back, you're off by an hour.
   The correct way here is to just call toEpochMillies(). PLEASE DO NOT CONVERT 
FORWARD BACKWARDS from to/local time.




----------------------------------------------------------------
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:
[email protected]


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

    Worklog Id:     (was: 489454)
    Time Spent: 5h 50m  (was: 5h 40m)

> 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 50m
>  Remaining Estimate: 0h
>




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

Reply via email to