Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2015-12-06 17:39:15 +0000
committerMatthias Sohn2015-12-06 23:47:41 +0000
commit0a871ac45d5f69fa97c49beddfe4437a61f87339 (patch)
treed1ce342c47e72bcafe55595864b69e8c5de16529
parentac7b0ce9d1f7a325d39a5bb24212b2f2cf356e7c (diff)
downloadegit-0a871ac45d5f69fa97c49beddfe4437a61f87339.tar.gz
egit-0a871ac45d5f69fa97c49beddfe4437a61f87339.tar.xz
egit-0a871ac45d5f69fa97c49beddfe4437a61f87339.zip
Fix DateFormatPreferencePage.getDifferentTimeZone
Make sure that the timezone offset remains in a sane range. Otherwise someone in Honolulu might get -16h, for which there is no time zone id. Change-Id: Icec59c22fe92142db198c0319b6e79b303694db3 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/DateFormatPreferencePage.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/DateFormatPreferencePage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/DateFormatPreferencePage.java
index 124854bfb9..52d2d3fbf6 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/DateFormatPreferencePage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/DateFormatPreferencePage.java
@@ -283,9 +283,17 @@ public class DateFormatPreferencePage extends FieldEditorPreferencePage
private static TimeZone getDifferentTimeZone() {
TimeZone localTimeZone = TimeZone.getDefault();
- int offset = (localTimeZone.getRawOffset() / 3600 / 1000 - 6) * 3600
- * 1000; // 6h to the West, full hour
- return TimeZone.getTimeZone(TimeZone.getAvailableIDs(offset)[0]);
+ int offset = (localTimeZone.getRawOffset() / 3600 / 1000 - 6);
+ // 6h to the West, full hour. Now get back to a sane range:
+ if (offset < -12) {
+ offset += 24;
+ }
+ String[] zoneIds = TimeZone.getAvailableIDs(offset * 3600 * 1000);
+ if (zoneIds.length == 0) {
+ // Huh?
+ return localTimeZone;
+ }
+ return TimeZone.getTimeZone(zoneIds[0]);
}
private static final class FormatInfo {

Back to the top