A Simple Test to Confirm a JDK or JRE is in Compliance with Changes to USA 2007 Daylight Saving Time (DST)
(Doc ID 409144.1)
Last updated on JUNE 10, 2024
Applies to:
Oracle Fusion Middleware - Version 9.0.4.0.0 to 10.1.3.5.1 [Release AS10g to AS10gR3]Oracle Containers for J2EE - Version 9.0.4.0.0 to 10.1.3.5.0 [Release AS10g to AS10gR3]
Information in this document applies to any platform.
Purpose
This document provides a simple test case to illustrate whether or not a specific Java Development Kit (JDK) or Java Runtime Environment (JRE) is correctly interpreting the changes to daylight saving time (DST) for the United States of America resulting from the Energy Policy Act of 2005.
Beginning in 2007, daylight saving time in the U.S. will begin on the second Sunday in March and end the first Sunday in November rather than beginning on the first Sunday in April and ending the last Sunday in October, as it did in the past. Under the new rules for 2007, DST will start on March 11, 2007 end on November 04, 2007.
This test case is very specific to the United States and contains hard coded values identifying the second prior to the commencement of the period when Daylight Savings takes effect. As such it is not appropriate to checking the expected behavior for regions other than the United States (such as Australia, New Zealand, Brazil etc.).
Scope
This document provides a test case that illustrates the effect of moving from day time into daylight saving time. The test case is applicable for the JDK 1.4.x and 1.5.x versions that can be used with currently supported versions of Application Server 9.0.4 and 10.1.3. However, the test will not work for the JDK 1.3.1 version in use with earlier, de-supported versions of Oracle Application server, since that JDK does not support the java.util.TimeZone class needed by the test.
In the U.S. during the Spring, when Daylight Saving Time commences, clocks change at 2:00 a.m. local time and spring forward from 1:59 a.m. to 3:00 a.m. For some time the start of DST has taken place on the first Sunday in April, as was the case in 2006. However, from 2007 onward the start of DST will be from the second Sunday in March.
Java represents system time as a long data type that represents the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC. During periods identified as being within the DST period an additional offset is added to the value maintained as system time to project the current time forward into the appropriate time for observation of DST.
This test case retrieves the long value representing the system time for the last second prior to the start of the DST period for a given year and illustrates the effect of adding 1 second (1000 milliseconds) to that long value. The result should illustrate that rather than springing forward by just one second, the formatted date for the incremented time springs forward by one hour.
The following table illustrates how the date is expected to change as a result for the start of DST in 2006 and 2007.
Year | DST Start Date | Last Second Before DST begins | Expected Time at next Second |
2006 | Sunday, April 2 | 01:59:59 | 03:00:00 |
2007 | Sunday, March 11 | 01:59:59 | 03:00:00 |
The test uses the java GregorianCalendar class to identify the long value representing the the last second before DST begins, increments this by 1000 to identify the system time for the second following this and then uses the java Date and SimpleDateFormat classes to display the date in a more readable form. In addition, the inDaylightTime(Date dt) method on the TimeZone class is used to confirm that the second preceding the start of DST and the second following it have different return values.
Details
To view full details, sign in with your My Oracle Support account. |
|
Don't have a My Oracle Support account? Click to get started! |
In this Document
Purpose |
Scope |
Details |
References |