|
|
|
@ -1,6 +1,5 @@
|
|
|
|
|
package com.hnac.hzims.operational.util; |
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
|
|
public class TimeUtils { |
|
|
|
@ -17,11 +16,18 @@ public class TimeUtils {
|
|
|
|
|
*/ |
|
|
|
|
public static Long getDifferTime(Date endDate, Date nowDate) { |
|
|
|
|
// long nd = 1000 * 24 * 60 * 60L;
|
|
|
|
|
// 获得两个时间的毫秒时间差异
|
|
|
|
|
// long nh = 1000 * 60 * 60L;
|
|
|
|
|
// long diff = endDate.getTime() - nowDate.getTime();
|
|
|
|
|
// BigDecimal s=BigDecimal.valueOf(diff).divide(BigDecimal.valueOf(diff)).setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
// Long hour=s.longValue();
|
|
|
|
|
// return hour;
|
|
|
|
|
long nd = 1000 * 24 * 60 * 60L; |
|
|
|
|
long nh = 1000 * 60 * 60L; |
|
|
|
|
// 获得两个时间的毫秒时间差异
|
|
|
|
|
long diff = endDate.getTime() - nowDate.getTime(); |
|
|
|
|
BigDecimal s=BigDecimal.valueOf(diff).divide(BigDecimal.valueOf(diff)).setScale(0, BigDecimal.ROUND_HALF_UP); |
|
|
|
|
Long hour=s.longValue(); |
|
|
|
|
// 计算差多少小时
|
|
|
|
|
long hour = diff % nd / nh; |
|
|
|
|
return hour; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|