/**判斷是否超過多少小時 如:24 * * @param tableTime 業務時間 * @param hour 多少小時 * @return boolean * @throws Exception */ public static boolean judgmentDate(String tableTime, Integer hour) throws Exception { String currentTime = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss");//當前時間 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d HH:mm:ss"); Date start = sdf.parse(tableTime);//業務時間 Date end = sdf.parse(currentTime);//當前時間 long cha = end.getTime() - start.getTime(); if (cha < 0) { return false; } double result = cha * 1.0 / (1000 * 60 * 60); if (result <= 24) { return true;//是小於等於 hour 小時 } else { return false; } }