//判断美国的时间是否在夏令时
public static boolean isDaylightTime(LocalDateTime a) {
LocalDateTime startDate = a.withMonth(3).toLocalDate().atTime(2, 0);
LocalDateTime startlightDay = startDate.with(TemporalAdjusters.dayOfWeekInMonth(2, DayOfWeek.SUNDAY));
//更新为11月
LocalDateTime endDate = a.withMonth(11).toLocalDate().atTime(1, 59,59);
LocalDateTime endlightDay = endDate.with(TemporalAdjusters.dayOfWeekInMonth(1, DayOfWeek.SUNDAY));
if (a.isBefore(startlightDay) || a.isAfter(endlightDay)) {
return false;
}
return true;
}
//传入指定时间和时区
public static boolean isDaylightTime(LocalDateTime a,ZoneId dest) {
ZonedDateTime z1 = a.atZone(dest);
ZoneRules rules = dest.getRules();
boolean flag = rules.isDaylightSavings(z1.toInstant());
return flag;
}