LocalDateTime 转换为时间戳 方法记录
如果传入hour参数为24则设置为第二天0时
public static long getMilliOfDateTimewithHour(LocalDateTime localDateTime, int hour) {
ZoneId zone = ZoneId.systemDefault();
if (hour == 24) {
Instant instant = localDateTime.plusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0)
.atZone(zone).toInstant();
return instant.toEpochMilli();
}
Instant instant = localDateTime.withHour(hour).withMinute(0).withSecond(0).withNano(0).atZone(zone)
.toInstant();
return instant.toEpochMilli();
}