You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2019/11/27 08:10:21 UTC

[GitHub] [incubator-doris] imay commented on a change in pull request #2309: Date format support java date style "yyyy-MM-dd HH:mm:ss"

imay commented on a change in pull request #2309: Date format support java date style "yyyy-MM-dd HH:mm:ss"
URL: https://github.com/apache/incubator-doris/pull/2309#discussion_r351140801
 
 

 ##########
 File path: fe/src/main/java/org/apache/doris/analysis/DateLiteral.java
 ##########
 @@ -433,6 +433,14 @@ public static DateLiteral dateParser(String date, String pattern) throws Analysi
     //Return the date stored in the dateliteral as pattern format.
     //eg : "%Y-%m-%d" or "%Y-%m-%d %H:%i:%s"
     public String dateFormat(String pattern) throws AnalysisException {
+        //Replace java date style : {"yyyyMMdd", "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss"}
+        pattern = pattern.replaceAll("yyyy", "%Y").
+                replaceAll("MM", "%m").
+                replaceAll("dd", "%d").
+                replaceAll("HH", "%H").
+                replaceAll("mm", "%i").
+                replaceAll("ss", "%s");
 
 Review comment:
   Is is a good idea to do like this?
   
   1. If user put an format like "%dd" or "%d-dd-%m", you will change it format.
   2. I think this modifing pattern work should be done by the client. For this case, it should be done by the from_unixtime function not here.
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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