LocalDateTime

最后一个是LocalDateTime,也是Java中最常用的Date / Time类,代表前两个累的组合 - 即日期和时间的值:

LocalDateTime dateTime = LocalDateTime.now(); // gets the current date and time
format的方式也一样

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss");
System.out.println(dateTime.format(formatter));
得到的日期结果类似于:

25-11-2018 00:57:20

 

posted @ 2019-09-02 19:07  水至清明  阅读(717)  评论(0编辑  收藏  举报