From db048fa114cbad7708c17c1d75639d9e06271011 Mon Sep 17 00:00:00 2001
From: yanghui <2536613402@qq.com>
Date: 星期四, 24 十一月 2022 17:18:27 +0800
Subject: [PATCH] #feat 调试问题修改
---
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/DateUtils.java | 51 ++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 46 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..052832e 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
@@ -926,11 +926,11 @@
}
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);
+
}
/**
@@ -1142,6 +1142,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 +1174,33 @@
}
}
+
+ 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;
+ }
}
--
Gitblit v1.7.1