LocalDateTime 转LocalDate
时间: 2023-10-18 22:27:03 浏览: 99
要将LocalDateTime转换为LocalDate,可以使用toLocalDate()方法。这个方法会返回LocalDate类型的对象。例如,可以使用以下代码进行转换:
LocalDateTime localDateTime = LocalDateTime.now();
LocalDate localDate = localDateTime.toLocalDate();
在这个例子中,localDateTime是当前的LocalDateTime对象,toLocalDate()方法将其转换为LocalDate对象并赋值给localDate变量。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [LocalDateTime、LocalDate、Date的相互转换(亲测LocalDateTime转LocalDate)](https://blog.csdn.net/gb4215287/article/details/118110352)[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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文