How to format Joda-Time DateTime to only mm/dd/yyyy?

前端 未结 9 1251
挽巷
挽巷 2020-11-29 15:52

I have a string \"11/15/2013 08:00:00\", I want to format it to \"11/15/2013\", what is the correct DateTimeFormatter pattern?

9条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-29 16:10

    Another way of doing that is:

    String date = dateAndTime.substring(0, dateAndTime.indexOf(" "));
    

    I'm not exactly certain, but I think this might be faster/use less memory than using the .split() method.

提交回复
热议问题