SimpleDateFormat类
1. parse()方法
String——》Date
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = df.parse("2015-05-12 15:52:13");
System.out.println(date);
Tue May 12 15:52:13 CST 2015
2.format()方法
Date——》String
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String format = df.format(new Date());
System.out.println(format);
2021-08-09 19:59:47