Java Date Time Java Java API
Class:
java.time.LocalDate
Method:
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.
Examples
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); } }
Output1990-07-10
|