Java Program to Add Months to the Current Date

You are currently viewing Java Program to Add Months to the Current Date

Java program to add months to the current date

// Java program to add months 
// to the current date

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Calendar cal = Calendar.getInstance();

    cal.add(Calendar.MONTH, 3);
    System.out.println("Date after 3 months: " + cal.getTime());
  }
}

Output

Date after 3 months: Sat Jul 02 05:53:39 GMT 2022

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply