Get day, month and year separately using SimpleDateFormat

前端 未结 8 868
無奈伤痛
無奈伤痛 2021-02-08 19:45

I have a SimleDateFormat like this

SimpleDateFormat format = new SimpleDateFormat(\"MMM dd,yyyy  hh:mm\");
String date = format.format(Date.parse(p         


        
8条回答
  •  温柔的废话
    2021-02-08 20:23

    Use this to parse "Jan,23,2014"

    SimpleDateFormat fmt = new SimpleDateFormat("MMM','dd','yyyy"); 
    Date dt = fmt.parse("Jan,23,2014");
    

    then you can get whatever part of the date.

提交回复
热议问题