morrySnow commented on code in PR #49033:
URL: https://github.com/apache/doris/pull/49033#discussion_r1995660692


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java:
##########
@@ -295,29 +295,32 @@ private static LocalDateTime firstDayOfWeek(LocalDateTime 
dateTime) {
     @ExecFunction(name = "date_format")
     public static Expression dateFormat(DateLiteral date, StringLikeLiteral 
format) {
         format = (StringLikeLiteral) 
SupportJavaDateFormatter.translateJavaFormatter(format);
-        return new 
VarcharLiteral(DateUtils.formatBuilder(format.getValue()).toFormatter(Locale.US).format(
+        return new 
VarcharLiteral(DateUtils.dateTimeFormatter(format.getValue()).format(
                 java.time.LocalDate.of(((int) date.getYear()), ((int) 
date.getMonth()), ((int) date.getDay()))));
     }
 
     @ExecFunction(name = "date_format")
     public static Expression dateFormat(DateTimeLiteral date, 
StringLikeLiteral format) {
         format = (StringLikeLiteral) 
SupportJavaDateFormatter.translateJavaFormatter(format);
-        return new 
VarcharLiteral(DateUtils.formatBuilder(format.getValue()).toFormatter(Locale.US).format(
+        return new 
VarcharLiteral(DateUtils.dateTimeFormatter(format.getValue())
+                .withResolverStyle(ResolverStyle.STRICT).format(
                 java.time.LocalDateTime.of(((int) date.getYear()), ((int) 
date.getMonth()), ((int) date.getDay()),
                         ((int) date.getHour()), ((int) date.getMinute()), 
((int) date.getSecond()))));
     }
 
     @ExecFunction(name = "date_format")
     public static Expression dateFormat(DateV2Literal date, StringLikeLiteral 
format) {
         format = (StringLikeLiteral) 
SupportJavaDateFormatter.translateJavaFormatter(format);
-        return new 
VarcharLiteral(DateUtils.formatBuilder(format.getValue()).toFormatter(Locale.US).format(
+        return new 
VarcharLiteral(DateUtils.dateTimeFormatter(format.getValue())
+                .withResolverStyle(ResolverStyle.STRICT).format(
                 java.time.LocalDate.of(((int) date.getYear()), ((int) 
date.getMonth()), ((int) date.getDay()))));
     }
 
     @ExecFunction(name = "date_format")
     public static Expression dateFormat(DateTimeV2Literal date, 
StringLikeLiteral format) {
         format = (StringLikeLiteral) 
SupportJavaDateFormatter.translateJavaFormatter(format);
-        return new 
VarcharLiteral(DateUtils.formatBuilder(format.getValue()).toFormatter(Locale.US).format(
+        return new 
VarcharLiteral(DateUtils.dateTimeFormatter(format.getValue())
+                .withResolverStyle(ResolverStyle.STRICT).format(

Review Comment:
   ```suggestion
                   .format(
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java:
##########
@@ -295,29 +295,32 @@ private static LocalDateTime firstDayOfWeek(LocalDateTime 
dateTime) {
     @ExecFunction(name = "date_format")
     public static Expression dateFormat(DateLiteral date, StringLikeLiteral 
format) {
         format = (StringLikeLiteral) 
SupportJavaDateFormatter.translateJavaFormatter(format);
-        return new 
VarcharLiteral(DateUtils.formatBuilder(format.getValue()).toFormatter(Locale.US).format(
+        return new 
VarcharLiteral(DateUtils.dateTimeFormatter(format.getValue()).format(
                 java.time.LocalDate.of(((int) date.getYear()), ((int) 
date.getMonth()), ((int) date.getDay()))));
     }
 
     @ExecFunction(name = "date_format")
     public static Expression dateFormat(DateTimeLiteral date, 
StringLikeLiteral format) {
         format = (StringLikeLiteral) 
SupportJavaDateFormatter.translateJavaFormatter(format);
-        return new 
VarcharLiteral(DateUtils.formatBuilder(format.getValue()).toFormatter(Locale.US).format(
+        return new 
VarcharLiteral(DateUtils.dateTimeFormatter(format.getValue())
+                .withResolverStyle(ResolverStyle.STRICT).format(
                 java.time.LocalDateTime.of(((int) date.getYear()), ((int) 
date.getMonth()), ((int) date.getDay()),
                         ((int) date.getHour()), ((int) date.getMinute()), 
((int) date.getSecond()))));
     }
 
     @ExecFunction(name = "date_format")
     public static Expression dateFormat(DateV2Literal date, StringLikeLiteral 
format) {
         format = (StringLikeLiteral) 
SupportJavaDateFormatter.translateJavaFormatter(format);
-        return new 
VarcharLiteral(DateUtils.formatBuilder(format.getValue()).toFormatter(Locale.US).format(
+        return new 
VarcharLiteral(DateUtils.dateTimeFormatter(format.getValue())
+                .withResolverStyle(ResolverStyle.STRICT).format(

Review Comment:
   ```suggestion
                   .format(
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java:
##########
@@ -539,7 +542,8 @@ public static Expression unixTimestamp(DateTimeV2Literal 
date) {
     @ExecFunction(name = "unix_timestamp")
     public static Expression unixTimestamp(StringLikeLiteral date, 
StringLikeLiteral format) {
         format = (StringLikeLiteral) 
SupportJavaDateFormatter.translateJavaFormatter(format);
-        DateTimeFormatter formatter = 
DateUtils.formatBuilder(format.getValue()).toFormatter();
+        DateTimeFormatter formatter = 
DateUtils.dateTimeFormatter(format.getValue())
+                .withResolverStyle(ResolverStyle.STRICT);

Review Comment:
   same problem



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java:
##########
@@ -295,29 +295,32 @@ private static LocalDateTime firstDayOfWeek(LocalDateTime 
dateTime) {
     @ExecFunction(name = "date_format")
     public static Expression dateFormat(DateLiteral date, StringLikeLiteral 
format) {
         format = (StringLikeLiteral) 
SupportJavaDateFormatter.translateJavaFormatter(format);
-        return new 
VarcharLiteral(DateUtils.formatBuilder(format.getValue()).toFormatter(Locale.US).format(
+        return new 
VarcharLiteral(DateUtils.dateTimeFormatter(format.getValue()).format(
                 java.time.LocalDate.of(((int) date.getYear()), ((int) 
date.getMonth()), ((int) date.getDay()))));
     }
 
     @ExecFunction(name = "date_format")
     public static Expression dateFormat(DateTimeLiteral date, 
StringLikeLiteral format) {
         format = (StringLikeLiteral) 
SupportJavaDateFormatter.translateJavaFormatter(format);
-        return new 
VarcharLiteral(DateUtils.formatBuilder(format.getValue()).toFormatter(Locale.US).format(
+        return new 
VarcharLiteral(DateUtils.dateTimeFormatter(format.getValue())
+                .withResolverStyle(ResolverStyle.STRICT).format(

Review Comment:
   ```suggestion
                   .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: [email protected]

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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to