datetime-local时间格式修该问题
public String timeFormat(String time) {
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
LocalDateTime localDateTime = LocalDateTime.parse(time.replaceAll("T", " ") + ":00", df);
Date date = Date.from( localDateTime.atZone( ZoneId.systemDefault()).toInstant());
Timestamp timestamp = new Timestamp(date.getTime());
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MMM-dd HH:mm");
String startTimeString=sf.format(timestamp);
return startTimeString;
}
public LocalDateTime DataTime(String time) {
LocalDateTime onDutyBegin =
LocalDateTime.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
return onDutyBegin;
}
![在这里插入图片描述](https://img-blog.csdnimg.cn/04aca812acda41b3826366891c5278ca.png)