Is there a way to tell the GregorianCalendar class to use a Time Zone that is one hour off GMT? I want to display a clock for a foreign country with its current time. I can get my System time, and I know the offset from GMT for the country in question. I can get the TimeZone for my location. Now, how do I change that to GMT plus the offset of the country I am working with? I've read most of the posts on JavaRanch and am looking at Sun's tutorials.
Hi Betty, Wouldn't it be easier just to create a SimpleTimeZone for the relevant country (rather than creating a "GMT+1" time zone)? Is not the country you require listed in the list returned by the "getAvailableIDs()" method in class java.util.TimeZone? In any case, the javadocs for the "TimeZone" class explain how to set up a "custom" time zone:
If the time zone you want is not represented by one of the supported IDs, then a custom time zone ID can be specified to produce a TimeZone. The syntax of a custom time zone ID is: CustomID: GMT Sign Hours : Minutes GMT Sign Hours Minutes GMT Sign Hours Sign: one of + - Hours: Digit Digit Digit Minutes: Digit Digit Digit: one of 0 1 2 3 4 5 6 7 8 9 Hours must be between 0 to 23 and Minutes must be between 00 to 59. For example, "GMT+10" and "GMT+0010" mean ten hours and ten minutes ahead of GMT, respectively.