From 28b988ca5dc4b51de34c6ebf996579723b2db414 Mon Sep 17 00:00:00 2001
From: lisy <java@lishouyideAir.lan>
Date: 星期五, 16 六月 2023 09:13:09 +0800
Subject: [PATCH] other模块——门店实体的添加;account模块——查询附近门店接口

---
 cloud-server-account/src/main/java/com/dsh/account/util/LocalDateTimeUtils.java |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/cloud-server-account/src/main/java/com/dsh/account/util/LocalDateTimeUtils.java b/cloud-server-account/src/main/java/com/dsh/account/util/LocalDateTimeUtils.java
index 87835a6..08fc7c1 100644
--- a/cloud-server-account/src/main/java/com/dsh/account/util/LocalDateTimeUtils.java
+++ b/cloud-server-account/src/main/java/com/dsh/account/util/LocalDateTimeUtils.java
@@ -1,9 +1,11 @@
 package com.dsh.account.util;
 
 import java.text.ParseException;
+import java.time.DayOfWeek;
 import java.time.Duration;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 
 /**
  * LocalDateTimeUtils
@@ -77,4 +79,31 @@
         Integer day=date.getDayOfMonth();
         return day < dayArr[month - 1] ? constellationArr[month - 1] : constellationArr[month];
     }
+
+    /**
+     * 获取当天的星期几
+     * @return
+     */
+    public static int getWeekStr(){
+        LocalDate today = LocalDate.now();
+        DayOfWeek dayOfWeek = today.getDayOfWeek();
+        return dayOfWeek.getValue();
+    }
+
+    public static String getWeekOfDays(int desiredDayOfWeek){
+        // 获取当前日期
+        LocalDate currentDate = LocalDate.now();
+
+        // 获取当前周的第一天(默认以星期一为一周的开始)
+        LocalDate firstDayOfWeek = currentDate.with(DayOfWeek.MONDAY);
+
+        LocalDate desiredDate = firstDayOfWeek.plusDays(desiredDayOfWeek - 1);
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM.dd");
+        return desiredDate.format(formatter);
+    }
+//
+//    public static void main(String[] args) {
+//        String weekOfDays = LocalDateTimeUtils.getWeekOfDays(4);
+//        System.out.println(weekOfDays);
+//    }
 }

--
Gitblit v1.7.1