zhuo
2025-02-17 9733594dd881627b4c00665e6f9bfbf08c1cacec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.ruoyi.common.utils;
 
import cn.hutool.core.date.DateUtil;
 
import java.time.LocalDateTime;
 
/**
 * @Author zhuo
 * @Date 2024/9/28
 */
public class LimsDateUtil {
 
 
    /**
     * 日期格式到26号月份加一
     * @param localDateTime
     * @return
     */
    public static String resetDate(LocalDateTime localDateTime) {
        // 获取当前日
        int dayOfMonth = localDateTime.getDayOfMonth();
 
        // 判断是否是26日及以上
        if (dayOfMonth >= 26) {
            // 月份加1
            localDateTime = localDateTime.plusMonths(1);
        }
 
        // 格式化为"yyMM"格式
        String formattedDate = DateUtil.format(localDateTime, "yyMM");
        return formattedDate;
    }
}