From 67b5d6fdb3ec4642c186ec95a27db3a5ce584fbd Mon Sep 17 00:00:00 2001
From: 1 <1@123>
Date: 星期二, 17 三月 2026 12:45:55 +0800
Subject: [PATCH] lsh#
---
rsf-server/src/main/java/com/vincent/rsf/server/common/utils/DateUtils.java | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/common/utils/DateUtils.java b/rsf-server/src/main/java/com/vincent/rsf/server/common/utils/DateUtils.java
index ff3c883..6543cc0 100755
--- a/rsf-server/src/main/java/com/vincent/rsf/server/common/utils/DateUtils.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/common/utils/DateUtils.java
@@ -6,7 +6,10 @@
import java.text.SimpleDateFormat;
import java.time.*;
import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
/**
* 鏃ユ湡鏃堕棿宸ュ叿绫�
@@ -230,6 +233,23 @@
SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
return dateFormat.parse(dateStr);
}
+
+ /**
+ * 鑾峰彇鍓�30澶╂墍鏈夋棩鏈�
+ * @param pattern
+ * @return
+ */
+ public static List<String> getLastMonthDays(String pattern) {
+ LocalDate today = LocalDate.now().minusDays(1);
+ LocalDate oneMonthAgo = today.minusMonths(1);
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
+ return IntStream.iterate(0, i -> i + 1)
+ .limit(ChronoUnit.DAYS.between(oneMonthAgo, today) + 1)
+ .mapToObj(oneMonthAgo::plusDays)
+ .map(date -> date.format(formatter))
+ .collect(Collectors.toList());
+ }
+
/**
* 鏃ユ湡鍨嬪瓧绗︿覆杞寲涓烘棩鏈� 鏍煎紡
@@ -724,3 +744,4 @@
return newDate;
}
}
+
--
Gitblit v1.9.1