This commit is contained in:
zt
2025-08-02 11:35:07 +08:00
parent e7bbe2f1ca
commit 7657697d34
26 changed files with 1473 additions and 3 deletions

View File

@ -159,6 +159,11 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
public static LocalDate parseLocalDateTime(final FormatsType format, final String ts) {
try {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format.getTimeFormat());
// 如果是年月格式,则默认设置为该月第一天
if (format.getTimeFormat().equals("yyyy-MM") || format.getTimeFormat().equals("yyyy/MM") || format.getTimeFormat().equals("yyyy.MM")) {
YearMonth yearMonth = YearMonth.parse(ts, formatter);
return yearMonth.atDay(1);
}
return LocalDate.parse(ts, formatter);
} catch (Exception e) {
throw new RuntimeException(e);