| | |
| | | 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 |
| | |
| | | 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); |
| | | // } |
| | | } |