Import Java.util.Date;
Import Java.text.SimpleDateFormat;
Import Java.util.Calendar;
public class TestDate {
public static void Main (string[] args) throws Exception {
Creates an object of a date format class that can format strings according to the specified template
SimpleDateFormat f=new SimpleDateFormat ("Yyyy-mm-dd");
Creates a new Date object with the value of the date derived from the string, formatted by F as the date
Date date1 =f.parse ("2005-1-31");
Creates a new Calendar object. Note: Class calendar is abstract to instantiate using getinstance (), or to instantiate its subclasses
Calendar Calen = Calendar.getinstance ();
Calendar object Default date is the current date, call SetTime set the date of the Calendar object to the date specified in the program
Calen.settime (date1);
Increase the calendar's Day by 5
Calen.add (calendar.day_of_year,5);
Gets the time of the Calendar object and assigns it to the Date object C
Date C=calen.gettime ();
Format c with F and output
System.out.println (F.format (c));
}
}