In the UK, I'd like to get the current offset from UTC/GMT. Currently the offset is 1 hour, but there seems to be no way of finding this.
Code
TimeZone timeZone = TimeZone.getDefault();
logger.debug("Timezone ID is '" + timeZone.getID() + "'");
if (timeZone.getID().equals("GMT")) {
timeZone = TimeZone.getTimeZone("Europe/London");
logger.debug("New timezone is '" + timeZone.getID() + "'");
}
Long eventDateMillis = Long.parseLong(eventDateValue.getKeyValue());
int timezoneOffset = timeZone.getOffset(eventDateMillis);
logger.debug("Offset for " + eventDateValue + "(" + eventDateMillis + ") using timezone " + timeZone.getDisplayName() + " is " + timezoneOffset);
returns debug output
Wed 2012/09/19 16:38:19.503|Debug|DataManagement|Timezone ID is 'GMT'
Wed 2012/09/19 16:38:19.503|Debug|DataManagement|New timezone is 'GMT'
Wed 2012/09/19 16:38:19.557|Debug|DataManagement|Offset for 18 Sep 2012 09:00(1347958800000) using timezone Greenwich Mean Time is 0
In other words, timezone 'GMT' is returning an offset of zero and I can't find how to set it to something that does return the correct offset.
If someone can provide a working code sample for JodaTime, that would do but I'd really like to avoid having to install a separate library just for what should be a one-liner.
The Java version is 7.