调用addDay即可
day:2019-03-01 也可精确到毫秒
n:增加的天数
//实现天数的增加
public static String addDay(String day,Integer n){
String f = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(f);
Date d1 = conversionToDate(day,f);
Calendar c = Calendar.getInstance();
c.setTime(d1);
c.add(Calendar.DAY_OF_MONTH, n);//利用Calendar 实现 Date日期+1天
d1 = c.getTime();
return sdf.format(d1);
}
//格式化时间
public static Date conversionToDate(String date, String format){
SimpleDateFormat sdf = new SimpleDateFormat(format);
Date d = null;
try {
d = sdf.parse(date);
} catch (ParseException e) {
e.printStackTrace();
}
return d;
}