LocalDate的isAfter和isBefore方法

isAfter相当于>,isBefore相当于<

String start = "2023/09/28 09:36:00";
String end = "2023/09/28 18:36:00";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
LocalDateTime now = LocalDateTime.now();
LocalDateTime startTime = LocalDateTime.parse(start,formatter);
LocalDateTime endTime = LocalDateTime.parse(end,formatter);
// isAfter = >
System.out.println(now.isAfter(startTime));  // true
// isBefore = <
System.out.println(now.isBefore(endTime));  // true

你可能感兴趣的:(java,java,前端,服务器)