//时间加上秒后的时间 日期
public static Date timePastTenSecond(Integer second,String otime) {
try {
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date dt=sdf.parse(otime);
Calendar newTime = Calendar.getInstance();
newTime.setTime(dt);
newTime.add(Calendar.SECOND,second);//日期加10秒
Date dt1=newTime.getTime();
// String retval = sdf.format(dt1);
return dt1;
}
catch(Exception ex) {
ex.printStackTrace();
return null;
}
}
调用
SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.HOUR_PATTERN);
Date newDate = new Date();
String currTime = sdf.format(newDate);
Date topEndTime = AmsUtil.timePastTenSecond(amsDetailPojo.getToptime().intValue(), currTime);
amsDetailPojo.setTopStartTime(newDate);
amsDetailPojo.setTopEndTime(topEndTime);