Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺
//时间加上秒后的时间 日期
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);
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/196796.html原文链接:https://javaforall.net