From 3a93e82c63d31f4e046c8a656063d228ce3325c2 Mon Sep 17 00:00:00 2001 From: fwq <582742538@qq.com> Date: 星期一, 09 一月 2023 11:59:51 +0800 Subject: [PATCH] 获取当前周所在周一0点 --- src/main/java/com/hx/util/DateUtil.java | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/hx/util/DateUtil.java b/src/main/java/com/hx/util/DateUtil.java index 5bcedbe..a52169c 100644 --- a/src/main/java/com/hx/util/DateUtil.java +++ b/src/main/java/com/hx/util/DateUtil.java @@ -766,4 +766,18 @@ month.roll(Calendar.DATE, -1); return month.getActualMaximum(Calendar.DATE) - Calendar.getInstance().get(Calendar.DAY_OF_MONTH); } + + /**鑾峰彇褰撳墠鏃堕棿鎵�鍦ㄥ懆鐨勫懆涓�00:00:00*/ + public static Date getMonday(Date date) { + Calendar calendar = Calendar.getInstance(Locale.CHINA); + calendar.setTime(date); + //浠ュ懆涓�涓洪鏃� + calendar.setFirstDayOfWeek(Calendar.MONDAY); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + //鍛ㄤ竴 + calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); + return calendar.getTime(); + } } -- Gitblit v1.8.0