| | |
| | | } |
| | | |
| | | /** |
| | | * 计算小时差 |
| | | * |
| | | * @param endDate |
| | | * @param startTime |
| | | * @return |
| | | */ |
| | | public static long timeDistanceHour(Date endDate, Date startTime) { |
| | | long nd = 1000 * 24 * 60 * 60; |
| | | long nh = 1000 * 60 * 60; |
| | | long diff = endDate.getTime() - startTime.getTime(); |
| | | long hour = diff % nd / nh; |
| | | return hour; |
| | | } |
| | | |
| | | /** |
| | | * 计算天数差 |
| | | * |
| | | * @param endDate |
| | | * @param startTime |
| | | * @return |
| | | */ |
| | | public static long timeDistanceDay(Date endDate, Date startTime) { |
| | | long nd = 1000 * 24 * 60 * 60; |
| | | long diff = endDate.getTime() - startTime.getTime(); |
| | | long day = diff / nd; |
| | | return day; |
| | | } |
| | | |
| | | /** |
| | | * 增加 LocalDateTime ==> Date |
| | | */ |
| | | public static Date toDate(LocalDateTime temporalAccessor) |