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);//  w  w w.j  a  v  a  2 s. c o  m
    }
  }
}

Result

Related Topic