Convert string to date then format the date

后端 未结 8 503
我寻月下人不归
我寻月下人不归 2020-12-03 07:52

I am formatting a string to a date using the code

String start_dt = \'2011-01-01\';

DateFormat formatter = new SimpleDateFormat(\"YYYY-MM-DD\"); 
Date date          


        
8条回答
  •  北荒
    北荒 (楼主)
    2020-12-03 08:29

    Tested this code

    java.text.DateFormat formatter = new java.text.SimpleDateFormat("MM-dd-yyyy");
    java.util.Date newDate = new java.util.Date();
    System.out.println(formatter.format(newDate ));
    

    http://download.oracle.com/javase/1,5.0/docs/api/java/text/SimpleDateFormat.html

提交回复
热议问题