Java8 - 如何知道夏令时是否在现在 [英] Java8 - how to know if daylight savings is on now
本文介绍了Java8 - 如何知道夏令时是否在现在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要了解现在是否使用新的Java 8 datetime类来实现夏令时。
我发现一个条目如何在jodatime中执行此操作:
I need to find out whether daylight savings is on now using the new Java 8 datetime classes. I found an entry how to do this in jodatime:
jodatime how to know if daylight savings is on
但是如何找到它?在Java 8中? (jodatime应该是类似的,但我找不到相应的方法java.time.ZonedDateTime.isStandardOffset())
But how can I find it out in Java 8? (jodatime should be kinda similar but I could not find the corresponding method java.time.ZonedDateTime.isStandardOffset())
感谢您的帮助
推荐答案
ZoneRules
包含您所隐藏的功能:
ZoneRules
contains the functionality you are intrested in:
public static boolean isDST(ZonedDateTime t) {
return t.getZone().getRules().isDaylightSavings(t.toInstant());
}
这篇关于Java8 - 如何知道夏令时是否在现在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文