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

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

                Author: ASF GitHub Bot
            Created on: 30/Jul/20 15:06
            Start Date: 30/Jul/20 15:06
    Worklog Time Spent: 10m 
      Work Description: chtompki commented on a change in pull request #124:
URL: https://github.com/apache/commons-io/pull/124#discussion_r463065642



##########
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:
       Curious here...what do you think happens if the TimeZone of the local 
datetime of the machine on which the code is running differs from the 
`TimeZone` embedded in the Instant. I worry that `instant.toEpochMilli();` 
might return the `Epoch` from the timezone of the instant which could be off by 
multiples of 30 minutes, and thus could yield differing results depending upon 
a user error here. Maybe we should convert the instant to the TimeZone of the 
machine before running `instant.toEpochMilli();`??




----------------------------------------------------------------
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: 464602)
    Time Spent: 3h 20m  (was: 3h 10m)

> 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
>
>          Time Spent: 3h 20m
>  Remaining Estimate: 0h
>




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

Reply via email to