Java GregorianCalendar add year

Description

Java GregorianCalendar add year

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 1 year 
    gc.add(Calendar.YEAR, 1);/*w  w  w.  j  a  v a  2s  .  c  o m*/
    System.out.println("Date:"+gc.getTime());

  }
}



PreviousNext

Related