package com.xjrsoft.xjrsoftboot; import cn.hutool.core.util.IdUtil; import com.google.gson.JsonArray; import com.xjrsoft.module.schedule.util.ScheduleUtil; import org.junit.jupiter.api.Test; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.Arrays; import java.util.Base64; import java.util.List; /** * @author dzx * @date 2023/12/4 */ public class FileTest { @Test void param() throws Exception { long timestamp = System.currentTimeMillis(); System.out.println("timestamp:" + timestamp); //生成签名 String sign = ScheduleUtil.createSign(timestamp); System.out.println("sign:" + sign); String startDateStr = "2024-07-29", endDateStr = "2024-08-16"; LocalDate startDateObj = LocalDate.parse(startDateStr); LocalDate endDateObj = LocalDate.parse(endDateStr); long between = ChronoUnit.DAYS.between(startDateObj, endDateObj); long times = (between / 7) + 1; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); for (int i = 0; i < times; i ++) { LocalDate statrTime = startDateObj.plusDays(i * 7L); String startDate = statrTime.format(formatter); LocalDate endTime = statrTime.plusDays(6L); if(endTime.isAfter(endDateObj)){ endTime = endDateObj; } String endDate = endTime.format(formatter); System.out.println("i =====================================-> " + i); System.out.println("startDate -> " + startDate); System.out.println("endDate -> " + endDate); } } @Test void idTest() throws Exception { System.out.println(IdUtil.getSnowflakeNextId()); String str = "[{\"label\":\"早自习课时单价:正式聘用\",\"field\":\"cost1\",\"value\":22},{\"label\":\"非正式聘用\",\"field\":\"cost2\",\"value\":33},{\"label\":\"正课课时单价:正式聘用\",\"field\":\"cost3\",\"value\":44},{\"label\":\"非正式聘用\",\"field\":\"cost4\",\"value\":43},{\"label\":\"晚自习课时单价:正式聘用\",\"field\":\"cost5\",\"value\":55},{\"label\":\"非正式聘用\",\"field\":\"cost6\",\"value\":134},{\"label\":\"超出课时单价:正式聘用\",\"field\":\"cost7\",\"value\":66},{\"label\":\"非正式聘用\",\"field\":\"cost8\",\"value\":13},{\"label\":\"超出课时标准(每周):正式聘用\",\"field\":\"cost9\",\"value\":77},{\"label\":\"非正式聘用\",\"field\":\"cost10\",\"value\":12},{\"label\":\"顶课课时单价:正式聘用\",\"field\":\"cost11\",\"value\":88},{\"label\":\"非正式聘用\",\"field\":\"cost12\",\"value\":99}]"; } @Test void idTest2() throws Exception { String timeNumbers = "5,6,7"; Arrays.asList(timeNumbers.split(",")); } @Test void idTest3() throws Exception { String filePath = "C:\\Users\\14263\\Desktop\\七日杀mod\\虹彩+隐匿的曙光\\item_modifiers.txt"; try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) { // 读取文件内容 StringBuilder base64ContentBuilder = new StringBuilder(); String currentLine; while ((currentLine = reader.readLine()) != null) { base64ContentBuilder.append(currentLine); } // 获取完整的 Base64 编码字符串 String base64EncodedString = base64ContentBuilder.toString(); // 解码 Base64 字符串 byte[] decodedBytes = Base64.getDecoder().decode(base64EncodedString); // 将解码后的字节数组转换为字符串(如果原内容是文本) String decodedString = new String(decodedBytes, StandardCharsets.UTF_8); // 输出解码后的内容 System.out.println("Decoded content:"); System.out.println(decodedString); // 如果解码后的数据是二进制文件(如图片、PDF等),可以将其保存为文件 // saveDecodedDataAsFile(decodedBytes, "output_file_path"); } catch (IOException e) { e.printStackTrace(); } } }