判断是否是周末或者节假日

   ``` 
    //判断是否是周末或者节假日
private boolean checkDate(String realityEnterPortTime) throws Exception {
	
	boolean result = false;
	//是否是周末
	DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    Date bdate = format1.parse(realityEnterPortTime);
    Calendar cal = Calendar.getInstance();
    cal.setTime(bdate);
    if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){
    	result = true;
    } else{
    	result = false;
    }

    //是否是节假日
    ConfigHolidayInfoPage holidayPage = new ConfigHolidayInfoPage();
    holidayPage.setRealityEnterPortTime(new SimpleDateFormat("yyyy-MM-dd").format(bdate));
    List<ConfigHolidayInfo> dataList = configHolidayInfoService.queryByList(holidayPage);
    if(dataList.size() > 0) {
    	result = true;
    } else{
    	result = false;
    }
    return result;
} 
posted @ 2021-04-23 17:14  yx袁祥  阅读(636)  评论(0)    收藏  举报