无关风月
2024-09-11 68d6a3d45e0cf9faf6ab0bc26f8bde4075c3567a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package com.ruoyi.order.util;
 
import java.time.LocalDate;
import java.time.Period;
import java.time.temporal.TemporalAdjusters;
 
public class PreviousSixMonths {
    public static LocalDate get() {
        // 获取当前日期
        LocalDate currentDate = LocalDate.now();
 
        // 计算六个月前的日期
        LocalDate sixMonthsAgo = currentDate.minusMonths(6);
 
        // 调整为该月的第一天
        LocalDate firstDayOfSixMonthsAgo = sixMonthsAgo.with(TemporalAdjusters.firstDayOfMonth());
        return firstDayOfSixMonthsAgo;
 
    }
}