Java8中LocalDateTime和Date的相互转换

Date to LocalDateTime

Date todayDate = new Date();

LocalDateTime ldt = todayDate.toInstant() .atZone( ZoneId.systemDefault() ) .toLocalDateTime();

LocalDateTime to Date

LocalDateTime localDateTime = LocalDateTime.now();

Date date = Date.from( localDateTime.atZone( ZoneId.systemDefault()).toInstant());

你可能感兴趣的:(Java8中LocalDateTime和Date的相互转换)