CodeCooker17 commented on code in PR #19265:
URL: https://github.com/apache/doris/pull/19265#discussion_r1187491181


##########
fe/fe-core/src/main/java/org/apache/doris/common/util/TimeUtils.java:
##########
@@ -305,4 +314,11 @@ public static LocalDateTime 
formatDateTimeAndFullZero(String datetime, DateTimeF
                 LocalTime.of(hour, minute, second, milliSecond * 1000000));
     }
 
+    private static String formatDateStr(String dateStr) {
+        String[] parts = dateStr.trim().split("[ :-]+");
+        return String.format("%s-%02d-%02d%s", parts[0], 
Integer.parseInt(parts[1]), Integer.parseInt(parts[2]),
+                parts.length > 3 ? String.format(" %02d:%02d:%02d", 
Integer.parseInt(parts[3]),
+                        Integer.parseInt(parts[4]), 
Integer.parseInt(parts[5])) : "");
+    }
+

Review Comment:
   SimpleDateFormat will try to parse it into a valid datetime according to 
certain rules when the incoming string does not exactly match the specified 
date format. For example, there is only one month in "2013-2-01", and 
SimpleDateFormat will format the string into "2013-02-01" for parsing. But 
DateTimeFormatter has strict format validation. So a formatting logic for date 
strings is added here to complete the month and day in the date format.



-- 
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: commits-unsubscr...@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to