From 179c4d64313c9b7572778da4aaaf6c6584fe457d Mon Sep 17 00:00:00 2001 From: mitao <2763622819@qq.com> Date: 星期二, 20 五月 2025 23:48:08 +0800 Subject: [PATCH] 修改文件上传类型限制 --- springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/DateUtils.java | 67 +++++++++++++++++++++++++++++++-- 1 files changed, 62 insertions(+), 5 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/DateUtils.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/DateUtils.java index 901f014..71bfc6d 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/DateUtils.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/DateUtils.java @@ -16,6 +16,7 @@ public static DateTimeFormatter format_ymdhms = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); public static DateTimeFormatter format_ymd = DateTimeFormatter.ofPattern("yyyy-MM-dd"); public static DateTimeFormatter format_ymdhms_string = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); + public static DateTimeFormatter format_ymdhms_yyyyMMddmmHHssSSS = DateTimeFormatter.ofPattern("yyyyMMddmmHHssSSS"); public static DateTimeFormatter format_ymdhms_no_signal = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); public static SimpleDateFormat yyyyMMdd_format = new SimpleDateFormat("yyyy-MM-dd"); public static SimpleDateFormat yyyy_MM_dd_format = new SimpleDateFormat("yyyy/MM/ddHH:mm:ss"); @@ -926,11 +927,13 @@ } public static void main(String[] args) throws Exception { - Date date= getLastMonthFirst(); - Date after = getLastMonthEnd(); - System.out.println(date); - System.out.println(after); - System.out.println(getMonthTwentyDay()); +// List<String> beforeDays = getBeforeDays(15); +// System.out.println(beforeDays); + List<String> yearMonths = getYearMonths(); + System.out.println(yearMonths); + List<String> latest12Month = getLatest12Month(LocalDate.now(), 10); + System.out.println(latest12Month); + } /** @@ -1142,6 +1145,18 @@ } /** + * 获取之前的日期 + * + * @return + */ + public static String getBeforeDay(Integer amount) { + Calendar cal = Calendar.getInstance(); + cal.setTime(new Date()); + cal.add(Calendar.DATE, -amount); + return DateUtil.format(cal.getTime(),"yyyy-MM-dd"); + } + + /** * 获取最近本月20天数据 * * @return @@ -1162,4 +1177,46 @@ } } + + public static List<String> getBeforeDays(int before) { + List<String> dates = new ArrayList<>(); + for (int i = before; i >= 0; i--) { + dates.add(getBeforeDay(i)); + } + return dates; + } + + /** + * 获取当年所有月份 + * + * @return + */ + public static List<String> getYearMonths() { + Calendar instance = Calendar.getInstance(); + int year = instance.get(Calendar.YEAR); + List<String> months = new ArrayList<>(); + for (int i = 1; i <= 12; i++) { + String result = String.valueOf(year); + if (i < 10) { + result = result + "-0" +i; + } else { + result = result + "-"+i; + } + months.add(result); + } + return months; + } + + //获取当前12个月 + public static List<String> getLatest12Month(LocalDate date,int num){ + List<String> monthList = new ArrayList<>(); + for(int i = 0;i <= num-1; i++){ + LocalDate localDate = date.minusMonths(i); + String month = localDate.toString().substring(0,7); + monthList.add(month); + } + return monthList; + } + + } -- Gitblit v1.7.1