推迟一周示例:
Calendar curr = Calendar.getInstance(); //获取当前时间
curr.set(Calendar.DAY_OF_MONTH,curr.get(Calendar.DAY_OF_MONTH)+7); //给当前时间增加一周
Date date=curr.getTime();//获取新的时间
推迟一个月示例:
Calendar curr = Calendar.getInstance();
curr.set(Calendar.MONTH,curr.get(Calendar.MONTH)+1); //增加一月
Date date=curr.getTime();
推迟一年示例:
Calendar curr = Calendar.getInstance();
curr.set(Calendar.YEAR,curr.get(Calendar.YEAR)+1); //增加一年
Date date=curr.getTime();
//判断是否是闰年
int years=curr.get(Calendar.YEAR);
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
//判断是否闰年,闰年366天
days = 366;
}else{
days=365;
}