DateTimeFormatter类用于将字符串解析为日期
常用方法:
1、staticofPattern(String pattern);
作用:按pattern字符串指定的格式创建DateTimeFormatter对象。
2、 LocalDateTime.parse(strDate, formatter);
作用:按指定模板和字符串创建LocalDateTime对象。
【案例】将字符串“2014-04-01:13:24:01“格式化为一个
LocalDateTime类的对象,并显示年、月、日、时、分和秒。