Converting a Timestamp from UTC to Etc/GMT+1

We have a webapp that reads a timestamp from a database. The displayed value is always 1 hour less than it should be. Obviously the system does not automatically recompute the (UTC-)timestamp according to our timezone.

What is the best way to convert the value of the timezone manually?

I tried the following, which works, but seems like a real bad approach.

.....

Timestamp timeStamp = rs.getTimestamp("CREATED");

Calendar cal =new GregorianCalendar();

cal.clear();

cal.setTimeZone(TimeZone.getTimeZone("Etc/GMT+1"));

cal.setTime(new java.util.Date(timeStamp.getTime()));

cal.add(Calendar.HOUR_OF_DAY, 1);

.....

Could anybody tell how to do this correctly?

Thanks!

[863 byte] By [bederta] at [2007-10-1 20:48:23]
# 1
DateFormat df = new SimpleDateFormat(...);df.setTimeZone(TimeZone.getTimeZone(...);System.out.println(df.format(timeStamp));
jverda at 2007-7-13 2:46:27 > top of Java-index,Desktop,I18N...
# 2

thanks for the answer. i've tried the following code now:

private String formatDateTime(Timestamp timeStamp){

DateFormat formatter = new SimpleDateFormat("y'-'MM'-'d' 'H':'m':'s", Locale.GERMANY);

formatter.setTimeZone(TimeZone.getTimeZone("ECT"));

return formatter.format(timeStamp);

}

but the output does not change, it is still the UTC value from the database. Am I doing something wrong?

regards

bederta at 2007-7-13 2:46:27 > top of Java-index,Desktop,I18N...
# 3
Assuming that's actually the code you're running (didn't forget to recompile or something), the only thing that pops to mind is that maybe ECT isn't a TZ that your system knows about. Maybe CEST? TimeZone.getAvailableIDs() will tell you which ones it knows about.
jverda at 2007-7-13 2:46:27 > top of Java-index,Desktop,I18N...
# 4

I've checked the available timezones like you recommended. The Zones I'm using exist. I also tried the following, which does not work either:

private String formatDateTime(Timestamp timeStamp){

DateFormat formatter = new SimpleDateFormat("y'-'MM'-'d' 'H':'m':'s");

formatter.setTimeZone(TimeZone.getTimeZone("Europe/Zurich"));

return formatter.format(timeStamp);

}

Any other idea?

bederta at 2007-7-13 2:46:27 > top of Java-index,Desktop,I18N...