This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Java in General and the fly likes Getting Default TimeZoneID, rawoffset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Getting Default TimeZoneID, rawoffset" Watch "Getting Default TimeZoneID, rawoffset" New topic
Author

Getting Default TimeZoneID, rawoffset

sri rallapalli
Ranch Hand

Joined: Mar 15, 2005
Posts: 88
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.

Regards,
Sri.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14117
    
  16

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:

US Daylight Savings Time Changes and the Java SE Platform: FAQ


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
sri rallapalli
Ranch Hand

Joined: Mar 15, 2005
Posts: 88
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?

Regards,
Sri.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14117
    
  16

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 ]
sri rallapalli
Ranch Hand

Joined: Mar 15, 2005
Posts: 88
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting Default TimeZoneID, rawoffset