直接上代码就完事了
DateTimeFormatter df
= DateTimeFormatter
.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime time
= LocalDateTime
.now();
String localTime
= df
.format(time
);
LocalDateTime ldt
= LocalDateTime
.parse(localTime
, df
);
System
.out
.println("LocalDateTime转成String类型的时间:" + localTime
);
System
.out
.println("String类型的时间转成LocalDateTime:" + ldt
);
引用:
https://www.cnblogs.com/chuzihang/p/8276983.html
转载请注明原文地址:https://tech.qufami.com/read-13304.html