Java - Compute Christmas days for the next five years using LocalDate and withYear method

Description

Compute Christmas days for the next five years using LocalDate and withYear method

Demo

import java.time.LocalDate;
import java.time.Month;
import java.time.Year;

public class Main {
  public static void main(String[] args) {
    LocalDate ld = LocalDate.of(Year.now().getValue(), Month.DECEMBER, 25);
    for (int i = 1; i <= 5; i++) {
      ld = ld.withYear(ld.getYear() + 1);
      System.out.println(ld);//from ww  w .ja va 2 s  .c om
    }
  }
}

Result

Related Topic