java 日期字符串与date相互转换
日期:date>String
Date date =
new
Date();
SimpleDateFormat sdf =
new
SimpleDateFormat(
"yyyy-MM-dd"
);
System.out.println(sdf.format(date));
日期:String>date
String string =
"2016-10-24 21:59:06"
;
SimpleDateFormat sdf =
new
SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss"
);
System.out.println(sdf.parse(string));