java判断一个日期是否为工作日
public class LocalDateTimeUtil {
public static Boolean isWorkDuration(Long seconds) {
LocalDateTime localDateTime = LocalDateTime.ofEpochSecond(seconds,0,ZoneOffset.ofHours(8));
DayOfWeek dayOfWeek = localDateTime.getDayOfWeek();
if (DayOfWeek.SATURDAY == dayOfWeek || DayOfWeek.SUNDAY == dayOfWeek) {
return false;
}
Long startAm = convertDateToLongSecond(localDateTime.withHour(9).withMinute(0).withSecond(0).withNano(0));
Long endAm = convertDateToLongSecond(localDateTime.withHour(12).withMinute(0).withSecond(0).withNano(0));
if (seconds >= startAm && seconds <= endAm) {
return true;
}
Long startPm = convertDateToLongSecond(localDateTime.withHour(13).withMinute(0).withSecond(0).withNano(0));
Long endPm = convertDateToLongSecond(localDateTime.withHour(18).withMinute(0).withSecond(0).withNano(0));
if (seconds >= startPm && seconds <= endPm) {
return true;
}
return false;
}
}