Java GregorianCalendar add month

Description

Java GregorianCalendar add month

import java.util.Calendar;
import java.util.GregorianCalendar;

public class Main {
  public static void main(String[] args) {
    GregorianCalendar gc = new GregorianCalendar();
    System.out.println("Date:" + gc.getTime());
    // Add 5 months
    gc.add(Calendar.MONTH,  5);/*w w w  . j a  v a2s. c o m*/
    System.out.println("Date:" + gc.getTime());

  }
}



PreviousNext

Related