yanghui
2022-11-28 42521c9b51c1bd9a40036f18fd610cd46601222d
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/DateUtils.java
@@ -926,8 +926,10 @@
    }
    public static void main(String[] args) throws Exception {
        List<String> beforeDays = getBeforeDays(15);
        System.out.println(beforeDays);
//        List<String> beforeDays = getBeforeDays(15);
//        System.out.println(beforeDays);
        List<String> yearMonths = getYearMonths();
        System.out.println(yearMonths);
    }
@@ -1181,4 +1183,24 @@
        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;
    }
}