DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime time = LocalDateTime.now();
String localTime = df.format(time);
LocalDateTime ldt = LocalDateTime.parse("2017-09-28 17:07:05",df);
System.out.println("LocalDateTime转成String类型的时间:"+localTime);
System.out.println("String类型的时间转成LocalDateTime:"+ldt);
控制台结果:
LocalDateTime转成String类型的时间:2017-09-30 10:40:06
String类型的时间转成LocalDateTime:2017-09-28T17:07:05
原文链接:http://blog.csdn.net/shaoyu_zhu_88/article/details/78140190