import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class CalculateDayUtil {
public static String getCalculateDay(Object initTime,Integer day){
String calculDate="";
Calendar instance = Calendar.getInstance();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date initDate=null;
if(null==initTime){
initDate=new Date();
}else if(initTime instanceof Date){
initDate=(Date)initTime;
}else{
try {
initDate = simpleDateFormat.parse((String) initTime);
} catch (ParseException e) {
e.printStackTrace();
}
}
instance.setTime(initDate);
instance.add(Calendar.DATE, day);
Date time = instance.getTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
calculDate = sdf.format(time);
return calculDate;
}
}
|