liujie
2026-02-05 b5a5e43e2ea7af773dba1ee99c2194be61515df8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.ruoyi.web.controller.tool;
 
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
 
import java.time.LocalDate;
 
public class HolidayUtil {
 
 
    public static boolean isHoliday() {
        String result = HttpUtil.get("https://publicapi.xiaoai.me/holiday/day?date=" + LocalDate.now());
        JSONObject jsonObject = JSONObject.parseObject(result);
        Object data = jsonObject.get("data");
        JSONArray parse = JSONArray.parse(data.toString());
        for (int i = 0; i < parse.size(); i++) {
            JSONObject jsonObject1 = parse.getJSONObject(i);
            if (jsonObject1.get("daytype").toString().equals("1")) {
                return true;
            }
        }
        return false;
    }
 
    public static void main(String[] args) {
        boolean holiday = isHoliday();
        System.out.println(holiday);
    }
    
}