public static long getTwoDay(Date begindate, Date enddate) {
long day = 0;
try {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String sdate = format.format(Calendar.getInstance().getTime());
//判断传入的时间不能为null
if(begindate !=null && enddate !=null){
day = (enddate.getTime() - begindate.getTime())/(24 * 60 * 60 * 1000);
}else{
return -1;
}
} catch (Exception e) {
return -1;
}
return day;
}
JAVA 计算两个日期相差的天数
最新推荐文章于 2023-01-18 10:16:44 发布