问题
I have a string something like date month year(31 08 2012) . I want to convert it to date format.
String string = "31082012";
Date date = new SimpleDateFormat("DDMMYYYY").parse(string);
System.out.println(date);
回答1:
Firstly, Your format is wrong, it should be ddMMyyyy
Date date = new SimpleDateFormat("ddMMyyyy").parse(string);
来源:https://stackoverflow.com/questions/15945428/how-to-convert-string-to-date-in-java