Close

Java Date Time - Year.plusYears() Examples

Java Date Time Java Java API 


Class:

java.time.Year

java.lang.Objectjava.lang.Objectjava.time.Yearjava.time.Yearjava.time.temporal.TemporalTemporaljava.time.temporal.TemporalAdjusterTemporalAdjusterjava.lang.ComparableComparablejava.io.SerializableSerializableLogicBig

Method:

public Year plusYears(long yearsToAdd)

Returns a copy of this Year with the specified number of years added.


Examples


package com.logicbig.example.year;

import java.time.Year;

public class PlusYearsExample {

public static void main(String... args) {
Year y = Year.of(2011);
System.out.println(y);

Year y2 = y.plusYears(50);
System.out.println(y2);

Year y3 = y.plusYears(-50);
System.out.println(y3);
}
}

Output

2011
2061
1961




See Also