// 根据某一时间获取该周的第一天
LocalDateTime withQuery1 = LocalDate.of(2023, 2, 3).atTime(LocalTime.MIN)
.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
// 根据某一时间获取该周的最后一天
LocalDateTime withQuery2 = LocalDate.of(2023, 2, 3).atTime(LocalTime.MIN)
.with(TemporalAdjusters.previousOrSame(DayOfWeek.SUNDAY));
// 根据某一时间获取当前月的第一天
LocalDateTime withQuery3 = LocalDate.of(2023, 2, 3).atTime(LocalTime.MIN)
.with(TemporalAdjusters.firstDayOfMonth());
// 根据某一时间获取当前月的最后一天
LocalDateTime withQuery4 = LocalDate.of(2023, 2, 3).atTime(LocalTime.MIN)
.with(TemporalAdjusters.lastDayOfMonth());
根据某一时间可以获取当前周的任意一天,改变那个枚举就好了!
/**
* The singleton instance for the day-of-week of Monday.
* This has the numeric value of {@code 1}.
*/
MONDAY,
/**
* The singleton instance for the day-of-week of Tuesday.
* This has the numeric value of {@code 2}.
*/
TUESDAY,
/**
* The singleton instance for the day-of-week of Wednesday.
* This has the numeric value of {@code 3}.
*/
WEDNESDAY,
/**
* The singleton instance for the day-of-week of Thursday.
* This has the numeric value of {@code 4}.
*/
THURSDAY,
/**
* The singleton instance for the day-of-week of Friday.
* This has the numeric value of {@code 5}.
*/
FRIDAY,
/**
* The singleton instance for the day-of-week of Saturday.
* This has the numeric value of {@code 6}.
*/
SATURDAY,
/**
* The singleton instance for the day-of-week of Sunday.
* This has the numeric value of {@code 7}.
*/
SUNDAY;