输入
输出
代码
String datastring = "8/24/22 6:00";
String[] arrDate = datastring.split("/", 3);
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(arrDate[0] + "/" + arrDate[1] + "/20" + arrDate[2]);
SimpleDateFormat inputDateFormat = new SimpleDateFormat("MM/dd/yyyy H:mm");
SimpleDateFormat outputDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date inputDate = inputDateFormat.parse(stringBuffer.toString());
Timestamp timestamp = Timestamp.valueOf(outputDateFormat.format(inputDate));
System.out.println(timestamp);