display Java.util.Date in a specific format

后端 未结 10 1909
没有蜡笔的小新
没有蜡笔的小新 2020-11-22 08:56

I have the following scenario :

SimpleDateFormat dateFormat = new SimpleDateFormat(\"dd/MM/yyyy\");
System.out.println(dateFormat.parse(\"31/05/2011\"));
         


        
10条回答
  •  余生分开走
    2020-11-22 09:21

    Use the SimpleDateFormat.format

    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    Date date = new Date();
    String sDate= sdf.format(date);
    

提交回复
热议问题