集册 Java实例教程 获得一年

获得一年

欢马劈雪     最近更新时间:2020-01-02 10:19:05

561
使用java.time.YearMonth类。
/* 来自 n o w j a v a . c o m - 时代Java*/

YearMonth yearMo = YearMonth.now(); 

System.out.println("Current Year and month:" + yearMo);       

YearMonth specifiedDate = YearMonth.of(2000, Month.NOVEMBER); 

System.out.println("Specified Year-Month: " + specifiedDate);