Quick test for Daylight Saving Time updates
I wrote a quick-and-dirty little ColdFusion page to test my various servers for DST updates. It shows the running java virtual machine version and then tests 3 dates: today, March 15, 2007, and April 15, 2007. The March and April dates should both show an offset of 1 if your server is running in a DST time zone affected by the change. If the March date shows zero, then you need to upgrade your JVM. The recommendation version is Sun's JDK 1.4.2_11. I installed 1.4.2_13 (the latest 1.4.x available) and seem to be running fine.
Here is the code:
PROGRAM: date.cfm
PURPOSE: test new DST rules
--->
<cfset sys=CreateObject("java","java.lang.System")>
<cfoutput>
<p>You are running
<strong>#sys.getProperty("java.vendor")#</strong>
jvm version
<strong>#sys.getProperty("java.version")#</strong>.
</p>
<hr />
</cfoutput>
<cfset today=now()>
<cfset march15=CreateDateTime(2007, 3, 15, 1, 0, 0)>
<cfset april15=CreateDateTime(2007, 4, 15, 1, 0, 0)>
<cfset t=CreateObject("java", "java.util.TimeZone").getDefault()>
<cfset cal=CreateObject("java", "java.util.GregorianCalendar").init(t)>
<cfset cal.setTime(today)>
<cfset offset_today=cal.get(cal.DST_OFFSET)/(60*60*1000)><!--- in hours --->
<cfset cal.setTime(march15)>
<cfset offset_march15=cal.get(cal.DST_OFFSET)/(60*60*1000)><!--- in hours --->
<cfset cal.setTime(april15)>
<cfset offset_april15=cal.get(cal.DST_OFFSET)/(60*60*1000)><!--- in hours --->
<cfoutput>
Time Zone = #t.getDisplayName()#<br />
Today offset=#offset_today#<br />
March 15 offset=#offset_march15#<br />
April 15 offset=#offset_april15#<br />
</cfoutput>

There are no comments for this entry.
[Add Comment]