java判断一个日期是否为工作日

java判断一个日期是否为工作日

/**
 * @Author :feiyang
 * @Date :Created in 7:47 PM 2019/12/3
 */
public class LocalDateTimeUtil {
    
    
/**
     * 判断指定时间是否在工作时间内
     * @author  feiyang
     * @param seconds
     * @return  java.lang.Boolean
     * @date    2020/1/13
     * @throws
     */
    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;
    }
}

猜你喜欢

转载自blog.csdn.net/qq_42133100/article/details/103979847