chengf
2025-10-28 2807cca4b6f2e8af204d798679dcee78e695ee28
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
34
35
36
37
package com.ruoyi.utils;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * @Author:yuankun
 * @Package:com.ruoyi.utils
 * @Project:ruoyi-vue-service
 * @name:GetCurrentWeek
 * @Date:2024/4/23 18:06
 * @Filename:GetCurrentWeek
 */
public class GetCurrentWeek {
    public static List<String> getPastWeekdays(String currentWeekday) {
        List<String> pastWeekdays = new ArrayList<>();
 
        String[] weekdays = {"星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"};
        int currentIndex = -1;
 
        for (int i = 0; i < weekdays.length; i++) {
            if (weekdays[i].equalsIgnoreCase(currentWeekday)) {
                currentIndex = i;
                break;
            }
        }
 
        if (currentIndex != -1) {
            for (int i = 0; i < 7; i++) {
                pastWeekdays.add(weekdays[currentIndex]);
                currentIndex = (currentIndex + 1 ) % weekdays.length;
            }
        }
 
        return pastWeekdays;
    }
}