DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;
//格式化 日期--->字符串
LocalDateTime localDateTime = LocalDateTime.now();
String str1 = formatter.format(localDateTime);
System.out.println(localDateTime);
System.out.println(str1);
//解析 字符串--->日期
TemporalAccessor parse = formatter.parse("2021-07-20T01:06:26.914");
System.out.println(parse);
//自定义的格式
DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("yyyy.MM.dd");
//格式化
String str2 = formatter1.format(LocalDateTime.now());
System.out.println(str2);
//解析 字符串转换为日期
TemporalAccessor parse2 = formatter1.parse("2021.07.20");
System.out.println(parse);