/**
* 计算两个时间相差秒数
* @param dateStr1
* @param dateStr2
* @return
*/
public static Long getDay(String dateStr1,String dateStr2){
// 获取日期
Date date1 = MyDateUtil.parseDate(dateStr1, "yyyy-MM-dd");
Date date2 = MyDateUtil.parseDate(dateStr2, "yyyy-MM-dd");
return (date2.getTime() - date1.getTime()) / (1000L*3600L*24L);
}
/**
* 当前时间加t秒
* @param time
* @param t
* @return
*/
public String getTime(String time,Long t){
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date date =df.parse(time);
date.setTime(date.getTime() + t*1000);
//System.out.println("当前时间 :"+df.format(date));
return df.format(date);
}catch (Exception e){
e.printStackTrace();
return null;
}
}