判断日期是不是节假日

现象:
判断日期是不是节假日

方法:通过访问网络地址传入时间参数进行判断
1:判断日期是不是节假日的方法
这里写图片描述

2:发送网络请求判断的方法
这里写图片描述

3:发送网络请求关闭输入输出流步骤
这里写图片描述

    /**
     * 确定是不是节假日,是节假日返回false ,工作日进行数据抓取返回true
     * 返回 2 :代表是法定节假日休息。1:正常休息日   0:工作日
     * @param newDate 
     * @return
     */
    public static boolean isHoliday(){
        try {
            SimpleDateFormat dft2 = new SimpleDateFormat("yyyyMMdd");
            String newDate=dft2.format(new Date());
            String url="http://api.goseek.cn/Tools/holiday?date="+newDate;
            String result=HttpSendPost.sendGet(url);
            TimeJson timeJson = (TimeJson) JSONObject.toBean(JSONObject.fromObject(result), TimeJson.class);
            if(timeJson.getData()==0){
                return true;
            }else{
                return false;
            }
        } catch (Exception e) {
            return false;
        }
    } 

猜你喜欢

转载自blog.csdn.net/hcwbr123/article/details/79472596