//时间加上秒后的时间 日期
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);
版权声明:本文为luojiawen208原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。