lisy
2023-07-14 cdd29e40b2cd26c5a4b405adc25cfe3711794bf6
cloud-server-course/src/main/java/com/dsh/course/util/DateTimeHelper.java
@@ -1438,6 +1438,24 @@
        return weekDays[w];
    }
    /**
     * 获取当前日期是星期几<br>
     * Obtain the day of the week for the current date.
     * @param dt
     * @return 当前日期是星期几
     */
    public static int getWeekNumOfDate(Date dt) {
        Integer[] weekDays = {7, 1, 2, 3, 4, 5, 6}; // 将周一的数值设为2,依次递增表示周二到周日
        Calendar cal = Calendar.getInstance();
        cal.setTime(dt);
        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if (w < 0) {
            w = 6; // 如果为负数,将其设为6,表示周日
        }
        return weekDays[w];
    }
    /**
     * 获取今天时间 2017-11-20 00:00:00
     */