Java 判断是否为工作时间
/** * 判断是否为工作时间(上午:7:30-11:30 下午:13:30-17:20) * @return */ public static boolean isWithinWorkingHours() { LocalTime currentTime = LocalTime.now(); // LocalTime currentTime = LocalTime.parse("17:19:59"); LocalTime morningStartWorkTime = LocalTime.of(7, 30); LocalTime morningEndWorkTime = LocalTime.of(11, 30); LocalTime afternoonStartWorkTime = LocalTime.of(13, 30); LocalTime afternoonEndWorkTime = LocalTime.of(17, 20); return (currentTime.isAfter(morningStartWorkTime) && currentTime.isBefore(morningEndWorkTime)) || (currentTime.isAfter(afternoonStartWorkTime) && currentTime.isBefore(afternoonEndWorkTime)); }