Fri Jun 26 00:00:00 CST 2020时间格式转换成yyyy-MM-dd时间(java)
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date startDate = tContract.getcContractStartDate();
Date endDate = tContract.getcContractEndDate();
String stDate= sdf.format(startDate); //开始时间格式化成yyyy-MM-dd格式的时间字符串
String enDate= sdf.format(endDate); //结束时间格式化成yyyy-MM-dd格式的时间字符串
try {
Date newStartDate =sdf.parse(stDate);
Date newEndDate =sdf.parse(enDate);
java.sql.Date resultStDate = new java.sql.Date(newStartDate.getTime());
java.sql.Date resultEnDate = new java.sql.Date(newEndDate.getTime());
tContract.setcContractStartDate(resultStDate);
tContract.setcContractEndDate(resultEnDate);
} catch (ParseException e) {
e.printStackTrace();
}