备份
This commit is contained in:
@@ -10,6 +10,9 @@ import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class OwnHttpUtils {
|
||||
@@ -25,9 +28,10 @@ public class OwnHttpUtils {
|
||||
|
||||
public static CalcResultVo getBaseCalc(String fileName, String personName) {
|
||||
// 目标接口地址
|
||||
String jsonBody = String.format("{\"file_name\":\"%s\",\"person_name\":\"%s\"}", fileName, personName);
|
||||
jsonBody = getResult("get_person_info",jsonBody);
|
||||
String jsonBody = String.format("{\"file_name\":%s,\"person_name\":\"%s\"}", fileName, personName);
|
||||
System.out.println(jsonBody);
|
||||
jsonBody = getResult("get_person_info",jsonBody);
|
||||
|
||||
// 1. 将 JSON 字符串解析成 JSONObject
|
||||
JSONObject jsonObject = JSON.parseObject(jsonBody);
|
||||
|
||||
@@ -107,12 +111,7 @@ public class OwnHttpUtils {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String fileName = "/home/ubuntu/lyq/fad_oa_kqdeal/202411.json";
|
||||
String personName = "丁苗松";
|
||||
String jsonBody = String.format("{\"file_name\":\"%s\",\"person_name\":\"%s\"}", fileName, personName);
|
||||
|
||||
|
||||
|
||||
StringToDate("2025-03");
|
||||
}
|
||||
|
||||
|
||||
@@ -164,4 +163,20 @@ public class OwnHttpUtils {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Date StringToDate(String dateStr) {
|
||||
|
||||
// 1. 解析字符串到 YearMonth(只包含年和月)
|
||||
YearMonth yearMonth = YearMonth.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM"));
|
||||
|
||||
// 2. 在 YearMonth 基础上指定“日”为 1
|
||||
LocalDate localDate = yearMonth.atDay(1);
|
||||
|
||||
// 3. 转成 Instant
|
||||
Instant instant = localDate.atStartOfDay(ZoneId.systemDefault()).toInstant();
|
||||
|
||||
// 4. 转成旧版本 Date
|
||||
return Date.from(instant);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user