diff --git a/src/main/java/org/caosdb/datetime/UTCTimeZoneShift.java b/src/main/java/org/caosdb/datetime/UTCTimeZoneShift.java index 7b259973148301b99b02c9880fe937ac3794d017..1e69cff7dd10bd3602c36860e195277a5289c774 100644 --- a/src/main/java/org/caosdb/datetime/UTCTimeZoneShift.java +++ b/src/main/java/org/caosdb/datetime/UTCTimeZoneShift.java @@ -127,15 +127,17 @@ public class UTCTimeZoneShift extends TimeZone { } /** - * Generate an ISO 8601 time zone offset string (e.g. +0200) from the given raw offset in - * milliseconds. + * Generate an ISO 8601 time zone offset string + * (e.g. +0200) for the current time * * @param timezone - the time zone in question. * @return ISO 8601 time zone offset. */ public static String getISO8601Offset(TimeZone timezone) { int divisor = 1000 * 60 * 60; + // get the offset of the given timezone to UTC at the current time int offset = timezone.getOffset(System.currentTimeMillis()); + // convert the ms to the ISO format int sign = Integer.signum(offset); int h = Integer.divideUnsigned(sign * offset, divisor); int m = Integer.remainderUnsigned(sign * offset, divisor);