This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
TimeZone in jdk1.1.8
Posted by Zarko Miloseski on August 23, 2000 at 2:31 AM
Could anyone offer any feedback on the following code;
Setting the time zone to be "GMT+10:00" doesn't seem to
reflect the 10 hours in the 'dateString'. I achieve this by
setting the row offset to 10 hours converted in milliseconds.
With jdk1.1.8 it appears that there is a need to set the time
zone and locale to get the correct local time. With jdk1.2
there is no need to deal with timezones and locales. Is there
a better way of this then below in jdk 1.1.8 . What will happen
if some one used the code below in a different time zone.
I did not think hard-coding the timezone and locale is a good
TimeZone timeZone = TimeZone.getTimeZone("GMT+10:00");
Locale loc = new Locale("en", "AU");
= new SimpleDateFormat
("dd-MM-yyyy G 'at' hh:mm:ss a zzz", loc);
Date currentTime = new Date();
String dateString = formatter.format(currentTime);
Any feedback would be greatly appreciated.
Thanks in advance,