Subtracting days from a date

The following example subtracts 200 days from the current date.

Main.java:

import java.util.*;
 
public class Main
{
   public static void main(String []args) {
      Calendar cal = Calendar.getInstance();
      cal.setTime(new Date());
      int year  = cal.get(Calendar.YEAR);
      int month = cal.get(Calendar.MONTH);
      int day   = cal.get(Calendar.DATE);
      month++;   // months are from 0-11, so add one!
 
      printDate(cal);
 
      cal.add(Calendar.DATE, -200);
 
      printDate(cal);
   }
 
   public static void printDate(Calendar cal) {
      System.out.println((cal.get(Calendar.MONTH)+1) + "-" +
                         cal.get(Calendar.DATE) + "-" +
                         cal.get(Calendar.YEAR));
   }
}

outputs:

4-28-2002
10-10-2001