Java Data Type How to - Get the same day next year








Question

We would like to know how to get the same day next year.

Answer

import java.time.LocalDate;
//from  ww w .ja  va2 s  . c  o m
public class Main {
  public static void main(String[] args) {
    LocalDate today = LocalDate.now();

    LocalDate nextYear = today.plusYears(1);

    System.out.println(String.format("Today %s and next year %s", today,
        nextYear));
  }
}

The code above generates the following result.