This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am trying to create a SimpleTimeZone object with the existing TimeZoneID, RawOffset, for that i need to have TimeZoneID, RawOffset, but i am not able to get them. I can get the TimeZone.getDefault().getDisplayName(). But i need ID. After creating the TimeZone with the existing, then i am trying to setStartRule(), setEndRule(), on the SimpleTimeZone object, for the DST changes for this Year. After that i am trying to set the SimpleTimeZone object as the Default TimeZone.
This is all for Doing the DST changes for this year. I know new version of Java is taking care, but i want to do it in older version of Java for our requirement.
Any light on How its implemented in new version of Java, also let me know what i am doing is correct or wrong.
If you want to get a TimeZone object for a specific timezone, then you are not supposed to instantiate SimpleTimeZone yourself. You should use the factory method getTimeZone(...) in class TimeZone, for example:
Class TimeZone has methods to list all the available timezone identifiers. Have a look at the API documentation of class TimeZone.
What version of Java are you using? Note that Sun has updates available for the DST change for Java 1.3.1, 1.4.2, 5.0 and 6.0. You might want to download and install the appropriate update instead of trying to do complicated things with timezones yourself. See this:
Hi, I am using Java1.1.7B version. I have done the DST changes, i have done stz.setStartRule(Calendar.MARCH,2,Calendar.SUNDAY,2*60*60*1000) stz.setEndRule(Calendar.NOVEMBER,1,Calendar.SUNDAY,2*60*60*1000), where stz is SimpleTimeZone object. Then i have done TimeZone.setDefault(stz); will it take care of forwarding and backwarding of time, or do i need to set the time 1 hour ahead, and behind during the DST?
Is there a special reason why you are using such an ancient version of Java? (Version 1.1.7 was released on September 28, 1998 according to this page; 8 years and 5 months ago...).
I would strongly recommend you to upgrade to a newer version. Compared to modern versions of Java, version 1.1 is very slow; it doesn't include the HotSpot VM. Also Java 1.1 is not supported by Sun anymore. [ February 26, 2007: Message edited by: Jesper Young ]
Joined: Mar 15, 2005
We are still using Swing with java1.1.7, to make it upgrade, there are lot of other issues, so we are looking for workaround solution. As a part of that, for doing the DST changes i doing this. Please suggest me, what can be done.