LocalDate 获取本周第一天
时间: 2023-08-24 19:12:04 浏览: 153
-获取一周的前一天的时间
根据提供的引用内容,可以使用以下代码来获取本周的第一天的年月日:
```
WeekFields weekFields = WeekFields.ISO;
LocalDate now = LocalDate.now();
LocalDate mondayDate = now.with(weekFields.dayOfWeek(), 1L);
```
这段代码中,`WeekFields.ISO`表示使用ISO标准的周字段,`LocalDate.now()`获取当前日期,`now.with(weekFields.dayOfWeek(), 1L)`将当前日期调整为本周的第一天。
#### 引用[.reference_title]
- *1* *2* [LocalDate获取本日所在周的周一和周日](https://blog.csdn.net/tyc_054600/article/details/127561152)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文