更新时间:2022-05-03 22:18:35
使用 SimpleDateFormat 解析和格式化日期:
Use SimpleDateFormat to parse and format the dates :
// Parse the input date
SimpleDateFormat fmt = new SimpleDateFormat("MM-dd-yyyy HH:mm");
Date inputDate = fmt.parse("10-22-2011 01:00");
// Create the MySQL datetime string
fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = fmt.format(inputDate);