From 75292374fad22b3c880bc544981cf84d1ead23b6 Mon Sep 17 00:00:00 2001 From: dy <2389062315@qq.com> Date: Fri, 18 Jul 2025 10:04:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=92=E7=8F=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dromara/property/utils/HolidayUtil.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 ruoyi-modules/Property/src/main/java/org/dromara/property/utils/HolidayUtil.java diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/utils/HolidayUtil.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/utils/HolidayUtil.java new file mode 100644 index 0000000..eba2b9b --- /dev/null +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/utils/HolidayUtil.java @@ -0,0 +1,36 @@ +package org.dromara.property.utils; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import org.json.JSONObject; + +/** + * 法定节假日工具类 + */ +public class HolidayUtil { + + public HolidayUtil() throws Exception { + // 调用jiejiariapi.com API获取节假日信息 + String baiduUrl = "https://api.jiejiariapi.com/v1/holidays/2025"; + JSONObject jiejiariapiResponse = getJsonFromUrl(baiduUrl); + } + + private static JSONObject getJsonFromUrl(String urlString) throws Exception { + URL url = new URL(urlString); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("GET"); + connection.connect(); + + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8")); + StringBuilder response = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + response.append(line); + } + reader.close(); + + return new JSONObject(response.toString()); + } +}