Write a Java Program to Add years to the current date


This Java program uses the Calendar class to add 3 years to the current date and time, and then prints out the resulting date and time. The program first creates a Calendar object using the getInstance() method, which returns a Calendar instance based on the current time zone and locale. It then calls the add() method on the Calendar object, passing in the Calendar.YEAR field and the value 3, which adds 3 years to the current date and time. Finally, the program prints out the resulting date and time using the getTime() method of the Calendar object, which returns a Date object representing the current date and time.

Source Code

import java.util.*;
public class AddYears_CurrentDate
{
	public static void main(String[] args)
	{
		Calendar cal = Calendar.getInstance();
		cal.add(Calendar.YEAR, 3);
		System.out.println("Date After 3 Years : " + cal.getTime());
	}
}

Output

Date After 3 Years : Wed Dec 17 14:25:09 IST 2025

Example Programs