| | |
| | | import java.time.LocalTime; |
| | | import java.time.ZoneId; |
| | | import java.time.ZonedDateTime; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.Date; |
| | | |
| | | import org.apache.commons.lang3.time.DateFormatUtils; |
| | |
| | | long sec = diff/ ns; |
| | | return sec; |
| | | } |
| | | |
| | | /** |
| | | * 获取一天中剩余的时间(秒数) |
| | | */ |
| | | public static Integer getDayRemainingTime(Date currentDate) { |
| | | 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; |
| | | } |
| | | } |