/**判断是否超过24小时
*
* @param date1
* @param date2
* @return boolean
* @throws Exception
*/
public static boolean judgmentDate(String date1, String date2) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d HH:mm:ss");
Date start = sdf.parse(date1);
Date end = sdf.parse(date2);
long cha = end.getTime() - start.getTime();
if(cha<0){
return false;
}
double result = cha * 1.0 / (1000 * 60 * 60);
if(result<=24){
return true;
}else{
return false;
}
}
java判断时间是否超过24小时
最新推荐文章于 2025-04-02 14:59:18 发布