mitao
2025-05-20 179c4d64313c9b7572778da4aaaf6c6584fe457d
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");
@@ -930,6 +931,8 @@
//        System.out.println(beforeDays);
        List<String> yearMonths = getYearMonths();
        System.out.println(yearMonths);
        List<String> latest12Month = getLatest12Month(LocalDate.now(), 10);
        System.out.println(latest12Month);
    }
@@ -1203,4 +1206,17 @@
        }
        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;
    }
}