Make the second argument negative in the 'add' method in Java

Description

The following code shows how to make the second argument negative in the 'add' method.

Example


//from  w ww .j a  v  a2 s . com
import java.util.Calendar;
import java.util.GregorianCalendar;

public class Main {
  public static void main(String[] a) {
    GregorianCalendar calendar = new GregorianCalendar();

    System.out.println(calendar.get(Calendar.YEAR));
    calendar.add(Calendar.YEAR, -14); 
    System.out.println(calendar.get(Calendar.YEAR));
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Date »




Date Get
Date Set
Date Format
Date Compare
Date Convert
Date Calculation
Date Parse
Timezone