判断两个Date类型的时间是否大于6天
new Date().toInstant() 是获取当前时间,并转换成Instant对象
cardDeviceTrajectoryInfo.getGpstime().toInstant() 是表中最后一条数据的时间,并转换成Instant对象
// 计算两个时间的间隔
long daysBetween = ChronoUnit.DAYS.between(new Date().toInstant(), cardDeviceTrajectoryInfo.getGpstime().toInstant());
long daysBetweenAbs = Math.abs(daysBetween);
System.out.println(new Date());
System.out.println(cardDeviceTrajectoryInfo.getGpstime());
System.out.println(daysBetweenAbs);
// 判断间隔是否大于6天
if (daysBetweenAbs > 6) {
System.out.println("两个时间间隔大于6天");
} else {
System.out.println("两个时间间隔不大于6天");
}