public static void main(String[] args) {
//时间戳毫秒转LocalDateTime
LocalDateTime localDateTime = new Date(1535444725000L).toInstant().atOffset(ZoneOffset.of("+8")).toLocalDateTime();
System.out.println(localDateTime);
System.out.println(getRemainSecondsOneDay(new Date()));
}
public static Integer getRemainSecondsOneDay(Date currentDate) {
//获取当前时间,到今晚12点的剩余秒
LocalDateTime midnight = LocalDateTime.ofInstant(currentDate.toInstant(),
ZoneId.systemDefault()).plusDays(1).withHour(0).withMinute(0)
.withSecond(0).withNano(0);
LocalDateTime currentDateTime = LocalDateTime.ofInstant(currentDate.toInstant(),
ZoneId.systemDefault());
long seconds = ChronoUnit.SECONDS.between(currentDateTime, midnight);
return (int) seconds;
}