提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
将一年和一个月合并以获得本地日期
import java.time.LocalDate;/** 来 自 NowJava.com - 时 代 Java**/ import java.time.Month; import java.time.MonthDay; import java.time.Year; import java.time.format.TextStyle; import java.util.Locale; public class Main { public static void main(String[] args) { MonthDay dec25 = MonthDay.of(Month.DECEMBER, 25); Year year = Year.now(); // Construct and print Christmas days in next five years for (int i = 1; i <= 5; i++) { LocalDate ld = year.plusYears(i).atMonthDay(dec25); int yr = ld.getYear(); String weekDay = ld.getDayOfWeek() .getDisplayName(