Groovy String to Date

后端 未结 7 1964
花落未央
花落未央 2020-12-02 11:45

I am coding this with Groovy

I am currently trying to convert a string that I have to a date without having to do anything too tedious.

String theD         


        
7条回答
  •  攒了一身酷
    2020-12-02 12:42

    Date#parse is deprecated . The alternative is :

    java.text.DateFormat#parse 
    

    thereFore :

     new SimpleDateFormat("E MMM dd H:m:s z yyyy", Locale.ARABIC).parse(testDate)
    

    Note that SimpleDateFormat is an implementation of DateFormat

提交回复
热议问题