String 数据类型转换成 Date
String inputDate = "2021-04-11";
Date outputDate = null;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
outputDate = format.parse(inputDate);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Date 数据类型转换成 String
Date outDate = "2021-04-11";
String outputDate = null;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
outputDate = format.format(outDate);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}