java8中LocalDateTime与Date相互转换

Date in = new Date();
LocalDateTime ldt = LocalDateTime.ofInstant(in.toInstant(), ZoneId.systemDefault());
Date out = Date.from(ldt.atZone(ZoneId.systemDefault()).toInstant());
String date = ldt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));

转载于:https://www.cnblogs.com/ak001/p/6768581.html

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