LocalDate

LocalDate只是一个日期,没有时间。 这意味着我们只能获得当前日期,但没有一天的具体时间。

LocalDate date = LocalDate.now(); // gets the current date
我们可以format它

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
System.out.println(date.format(formatter));
得到的结果只有年月日,例如:

25-11-2018
————————————————

原文地址:https://www.cnblogs.com/hyhy904/p/11448328.html