PROGRAM IN JAVA USING CALENDAR CLASS

import java.util.Calendar;
class UserCalendar
{
     public static void main(String[] args)
     {

      Calendar ca= Calendar.getInstance();
      System.out.println("Current Date is:"+ca.getTime());

      ca.add(Calendar.DATE,-15);
      System.out.println("15 days ago: "+ca.getTime());

      ca.add(Calendar.MONTH,4);
      System.out.println("4 months later : "+ca.getTime());

       ca.add(Calendar.YEAR,2);
       System.out.println("2 years later: "+ca.getTime());
       }

}

SAMPLE OUTPUT





No comments:

Post a Comment