可以使用localDateTime.atZone(ZoneId.systemDefault()).toInstant()LocalDateTime转换为Instant,然后使用Date.from(instant)Instant转换为Date

示例代码:

LocalDateTime localDateTime = LocalDateTime.now();
Instant instant = localDateTime.atZone(ZoneId.systemDefault()).toInstant();
Date date = Date.from(instant);
java localdatetime 转 date

原文地址: https://www.cveoy.top/t/topic/fiSk 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录