Does Java 8's new Java Date Time API take care of DST?

后端 未结 3 1054
情深已故
情深已故 2020-12-01 09:27

I am thinking of using the new java 8 Date Time API. I googled a bit and found jodaTime as good choice for java but still kind of interested to see how this

3条回答
  •  执念已碎
    2020-12-01 10:09

    Yes, the Java API will take DST changes into account.

    This tutorial explains quite well how to convert dates between timezones and how to choose the right class to represent a date: https://docs.oracle.com/javase/tutorial/datetime/iso/timezones.html

    You can also look at this class which represents the rules for each zone: http://docs.oracle.com/javase/8/docs/api/java/time/zone/ZoneRules.html

    In particular, this method can tell you if a particular instant is in daylight savings: http://docs.oracle.com/javase/8/docs/api/java/time/zone/ZoneRules.html#isDaylightSavings-java.time.Instant-

提交回复
热议问题