Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting Default TimeZoneID, rawoffset

 
sri rallapalli
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15272
37
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
sri rallapalli
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15272
37
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic