localdatetime转换date
要将LocalDateTime转换为Date,可以使用以下方法:
LocalDateTime localDateTime = LocalDateTime.now();
Date date = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
此方法首先使用atZone()方法将LocalDateTime转换为ZonedDateTime,然后使用toInstant()方法将其转换为Instant,最后使用from()方法将Instant转换为Date。
原文地址: https://www.cveoy.top/t/topic/hHKK 著作权归作者所有。请勿转载和采集!