liuchunhua commented on code in PR #22740:
URL: https://github.com/apache/doris/pull/22740#discussion_r1288143815


##########
fe/fe-core/src/main/java/org/apache/doris/external/iceberg/util/IcebergUtils.java:
##########
@@ -372,23 +375,23 @@ private static Object extractDorisLiteral(Expr expr) {
             return boolLiteral.getValue();
         } else if (expr instanceof DateLiteral) {
             DateLiteral dateLiteral = (DateLiteral) expr;
-            DateTimeFormatter formatter = 
DateTimeFormatter.ofPattern("yyyyMMddHHmmss")
-                    .withZone(ZoneId.systemDefault());
-            StringBuilder sb = new StringBuilder();
-            sb.append(dateLiteral.getYear())
-                    .append(dateLiteral.getMonth())
-                    .append(dateLiteral.getDay())
-                    .append(dateLiteral.getHour())
-                    .append(dateLiteral.getMinute())
-                    .append(dateLiteral.getSecond());
+
+            String formatDate = String.format("%04d%02d%02d%02d%02d%02d",
+                    dateLiteral.getYear(),
+                    dateLiteral.getMonth(),
+                    dateLiteral.getDay(),
+                    dateLiteral.getHour(),
+                    dateLiteral.getMinute(),
+                    dateLiteral.getSecond());
             Date date;
             try {
                 date = Date.from(
-                        LocalDateTime.parse(sb.toString(), 
formatter).atZone(ZoneId.systemDefault()).toInstant());
+                        LocalDateTime.parse(formatDate, 
dateFormatter).atZone(ZoneId.systemDefault()).toInstant());
             } catch (DateTimeParseException e) {
+                LOG.error("Failed to parse date from \"" + formatDate + "\".");
                 return null;
             }
-            return date.getTime();
+            return date.getTime() * MILLIS_TO_NANO_TIME;

Review Comment:
   DateLiteral has 'unixTimestamp' method



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