Java Date Time Java Java API
java.time.LocalDate
public LocalDate withYear(int year)
This method returns a new copy of this local date, with 'year' field replaced with the provided 'year' value.
If the provided year value is invalid, DateTimeException is thrown.
package com.logicbig.example.localdate;import java.time.LocalDate;public class WithYearExample { public static void main (String... args) { LocalDate d = LocalDate.of(2016, 7, 10); LocalDate d1 = d.withYear(1990); System.out.println(d1); }}
1990-07-10