Alberne commented on code in PR #9526:
URL: https://github.com/apache/seatunnel/pull/9526#discussion_r2299980159


##########
seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/AbstractReadStrategy.java:
##########
@@ -144,6 +151,46 @@ public List<String> getFileNamesByPath(String path) throws 
IOException {
         return fileNames;
     }
 
+    protected boolean filterFileByModificationDate(FileStatus fileStatus) {
+
+        long fileModifiedTime = fileStatus.getModificationTime();
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd 
HH:mm:ss");
+        Date startTime = null;
+        Date endTime = null;
+        try {
+            if (fileModifiedStartDate != null) {
+                startTime = dateFormat.parse(fileModifiedStartDate);
+            }
+
+            if (fileModifiedEndDate != null) {
+                endTime = dateFormat.parse(fileModifiedEndDate);
+            }
+
+        } catch (ParseException e) {
+            log.warn(
+                    "Failed to parse file modified date format: yyyy-MM-dd 
HH:mm:ss, please check file_filter_modified_start or file_filter_modified_end 
format.");
+            return false;
+        }

Review Comment:
   @Hisoka-X Thanks for your suggestion.  I can move the parsing logic to the 
`setPluginConfig` method. What would you propose instead ?
   
   The code snippet:
   
       @Override
       public void setPluginConfig(Config pluginConfig) {
           this.pluginConfig = pluginConfig;
   
           ........
   
           if 
(pluginConfig.hasPath(FileBaseSourceOptions.FILE_FILTER_MODIFIED_START.key())) {
               fileModifiedStartDate =
                       getFileModifiedDate(
                               pluginConfig.getString(
                                       
FileBaseSourceOptions.FILE_FILTER_MODIFIED_START.key()));
           }
           if 
(pluginConfig.hasPath(FileBaseSourceOptions.FILE_FILTER_MODIFIED_END.key())) {
               fileModifiedEndDate =
                       getFileModifiedDate(
                               pluginConfig.getString(
                                       
FileBaseSourceOptions.FILE_FILTER_MODIFIED_END.key()));
           }
       }
   
         
           `



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to