https://blog.csdn.net/nhjdcsdn/article/details/121648532?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-1-121648532-blog-101522476.pc_relevant_antiscanv2&spm=1001.2101.3001.4242.2&utm_relevant_index=3
第一种转换方法,借助新增类ZoneId、Instant、ZonedDateTime
public static void date2Local() { Date date = new Date(); //返回当前系统默认的时区 ZoneId zoneId = ZoneId.systemDefault(); //atZone()方法返回在指定时区,从该Instant生成的ZonedDateTime ZonedDateTime zonedDateTime = date.toInstant().atZone(zoneId); LocalDate localDate = zonedDateTime.toLocalDate(); LocalTime localTime = zonedDateTime.toLocalTime(); LocalDateTime localDateTime = zonedDateTime.toLocalDateTime(); }