Import Java.text.SimpleDateFormat;
Import Java.util.Calendar;
Import Java.util.Date;
public class Datetestutil {
public static void Main (string[] args) throws Exception {
SimpleDateFormat sdf=new SimpleDateFormat ("YyyyMMdd");
String str= "20110823";
Date dt=sdf.parse (str);
Calendar RightNow = Calendar.getinstance ();
Rightnow.settime (DT);
Rightnow.add (calendar.year,-1);//date minus 1 years
Rightnow.add (calendar.month,3);//date plus 3 months
Rightnow.add (calendar.day_of_year,10);//date plus 10 days
Date Dt1=rightnow.gettime ();
String restr = Sdf.format (DT1);
System.out.println (RESTR);
}
}
Note: In the Add method of the Calendar object, the second parameter is a positive number for "plus" and a negative number for "minus".
"Turn from": http://blog.sina.com.cn/s/blog_4be6505c0100vvoz.html
"Go" Java Add and subtract dates from date class, year plus minus, month plus minus