//日期转换时间戳 毫秒
public static String dateToStamp(String s) throws Exception {
String res;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = simpleDateFormat.parse(s);
long time = date.getTime();
res = String.valueOf(time);
return res;
}
//计算相差多少小时
public static int differHours(String startTime,String endTime)throws Exception{
int hour=0;
try {
String startStamp=dateToStamp(startTime);//登记时间戳
String endStamp=dateToStamp(endTime);//整改期限时间戳
BigInteger startStampInt=BigInteger.valueOf(Long.valueOf(startStamp));
BigInteger endStampInt=BigInteger.valueOf(Long.valueOf(endStamp));
BigInteger apartStamp=endStampInt.subtract(startStampInt);
BigInteger hourStamp=BigInteger.valueOf(Long.valueOf(1000*60*60));
BigInteger hours=apartStamp.divide(hourStamp);//相差几小时
hour=hours.intValue();
}catch (Exception e){
}
return hour;
}