java日期天数修改
public Date getDate(String dates){
SimpleDateFormat sdf= new SimpleDateFormat("yyyy年-MM月-dd日");
Date date=null;
try {
date = sdf.parse(dates);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(date);
return date;
}
protected static Date addDateOneDay(Date date){
if(null==date){
return date;
}
Calendar c=Calendar.getInstance();
// c.setTime(date); 设置当前时间
c.add(Calendar.DATE, 1);//日期加1天
date=c.getTime();
return date;
}
protected static String addOneDay(String dates) throws ParseException{
DateFormat df = new SimpleDateFormat("EEE MMM dd HH:mm:ss ‘CST‘ yyyy",Locale.US);
//把字符串转换成CST日期类型
Date date = df.parse(dates);
//System.out.println(date);
DateFormat sdf = new SimpleDateFormat("yyyy年-MM月-dd日");
//把CST格式转换成普通日期格式
String addOneDay=sdf.format(date);
return addOneDay;
}