import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class HelloWorld {
public static void main(String[] args) {
//指定时间输出格式
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date dt = new Date();
System.out.println("当前时间:" + sdf.format(dt));
Calendar rightNow = Calendar.getInstance();
rightNow.setTime(dt);
rightNow.add(Calendar.YEAR,-1);//当时日期减1年
System.out.println("减1年:" + sdf.format(rightNow.getTime()));
rightNow.add(Calendar.MONTH,3);//(在刚才的结果上)再加3个月
System.out.println("再加3个月:" + sdf.format(rightNow.getTime()));
rightNow.add(Calendar.DAY_OF_YEAR,10);//(在刚才的结果上)再加10天
System.out.println("再加10天:" + sdf.format(rightNow.getTime()));
}
}