Formatting date in java

前端 未结 5 1390
孤独总比滥情好
孤独总比滥情好 2021-01-26 07:04

I am trying to format date string ex. 2014-11-24T18:30:00.000Z to 2014-11-24 using this code below:

SimpleDateFormat dateFormat = new          


        
5条回答
  •  一整个雨季
    2021-01-26 07:14

    Use dateFormat.parse() instead of dateFormat.format(), since you want to parse your String into Date object. Then, when you have the Date object, format it to String with wanted format. @Jens already gave you the full code, so no need to copy it again here.

提交回复
热议问题