LocalDate与Date相互转换

1.LocalDate转Date

        LocalDate date = LocalDate.of(2006,07,26);
        ZoneId zone = ZoneId.systemDefault();
        Instant instant = date.atStartOfDay().atZone(zone).toInstant();
        java.util.Date da = Date.from(instant);

2.Date转LocalDate

           Instant instant =new Date().toInstant();
           ZoneId zone = ZoneId.systemDefault();
           LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, zone);
           LocalDate localDate= localDateTime.toLocalDate();

你可能感兴趣的:(Java,java)