Entries Tagged as 'Java'

Find timezone offset for a specific date

ColdFusion , Java 1 Comment »

ColdFusion's built in function getTimeZoneInfo() doesn't allow you to pass a date. It give you the server timezone info and offset as of "now" (as in, when the code is run). 

If you need to find the timezone offset for a specific date, you can use the TimeZone class from java. Here is the code.



<cfset myDate = "11/01/09" />
<cfset timeZone = createObject("java","java.util.TimeZone") />
<cfset myTimeZone = timeZone.getTimeZone("America/New_York") />
<cfset myTimeZoneOffset = myTimeZone.getOffset(1,year(myDate),month(myDate),day(myDate),dayOfWeek(myDate),0) />

 

Powered by Mango Blog. Design and Icons by N.Design Studio
RSS Feeds