您的位置:首页 > 其它

LocalDateTime与String日期互相转换

2017-09-30 10:33 531 查看
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

               
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: