DateTimeFormatter
常用方法
![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/980b0f31a3c94e15984b23601afec481.png)
代码
package NewTime;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class Test_geshihua {
public static void main(String[] args) {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH时mm分ss秒");
LocalDateTime now = LocalDateTime.now();
System.out.println(now);
String rs = now.format(dtf);
System.out.println(rs);
System.out.println("----------------------");
String rs1 = now.format(dtf);
System.out.println(rs1);
String str = "2020年08月31日 03时03分12秒";
LocalDateTime ldt = LocalDateTime.parse(str,dtf);
System.out.println(ldt);
}
}
![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/5abcb9f5567c45f5a6bc7c4f33b0733d.png)