public static void main(String[] args) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//超时时间
LocalDateTime timeoutTime = LocalDateTime.parse("2024-02-20 12:00:00", dateTimeFormatter);
System.out.println("============超时时间");
System.out.println(dateTimeFormatter.format(timeoutTime));
//当前时间
LocalDateTime now = LocalDateTime.parse("2024-02-20 12:00:59", dateTimeFormatter);
//当前分钟内
LocalDateTime min = now.withSecond(0);
LocalDateTime max = now.withSecond(59);
System.out.println("===============当前时间相关");
System.out.println(dateTimeFormatter.format(now));
System.out.println(dateTimeFormatter.format(min));
System.out.println(dateTimeFormatter.format(max));
if ((timeoutTime.isAfter(min) || timeoutTime.isEqual(min))
&& (timeoutTime.isBefore(max) || timeoutTime.isEqual(max))) {
System.out.println("当前时间属于超时时间内");
} else {
System.out.println("当前时间不属于超时时间内");
}
}