方式一:
String startdate="2013-09-10";
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-mm-dd");
Date date=sdf.parse(startdate);
Calendar cld=Calendar.getInstance();
cld.setTime(date);
cld.add(Calendar.DATE, 1);
System.out.println(sdf.format(cld.getTime()));
===================================
public
class
$ {
public
static
void
main(String[] args) {
Format f =
new
SimpleDateFormat(
"yyyy-MM-dd"
);
Date today =
new
Date();
System.out.println(
"今天是:"
+ f.format(today));
Calendar c = Calendar.getInstance();
c.setTime(today);
c.add(Calendar.DAY_OF_MONTH,
1
);
// 今天+1天
Date tomorrow = c.getTime();
System.out.println(
"明天是:"
+ f.format(tomorrow));
}
}
结果:
今天是:
2013
-
10
-
09
明天是:
2013
-
10
-
10
方式二:
String startdate="2013-09-10";
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-mm-dd");
Date date=null;
date = sdf.parse(startdate);
long t=date.getTime();
t+=24*60*60*1000;
date.setTime(t);
System.out.println(sdf.format(date));
方式三:
String startdate="2013-09-10";
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-mm-dd");
Date d = sdf.parse(startdate);
d.setDate(d.getDate() + 1);
startdate = sdf.format(d);
System.out.println(startdate);
增加一月
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, 1);
System.out.println(sdf.format(calendar.getTime()));