diff options
author | Sven de Marothy <sven@physto.se> | 2005-04-27 20:47:40 +0200 |
---|---|---|
committer | Michael Koch <mkoch@gcc.gnu.org> | 2005-04-27 18:47:40 +0000 |
commit | 465ee71e97935394f5aafbe32ae9b6f3f3ecb434 (patch) | |
tree | 44e3bdb3d870bb980657ebea614e9d5b0c9fbe9e /libjava/java/util | |
parent | a8efb5bb1e73551b6d1eef99bf96ea7df3837246 (diff) | |
download | gcc-465ee71e97935394f5aafbe32ae9b6f3f3ecb434.tar.gz |
2005-04-27 Sven de Marothy <sven@physto.se>
* java/util/TimeZone.java,
(getDefaultDisplayName): Fix previous fix.
2005-04-27 Sven de Marothy <sven@physto.se>
* java/util/TimeZone.java,
(getDefaultDisplayName): Don't print zero offsets.
From-SVN: r98874
Diffstat (limited to 'libjava/java/util')
-rw-r--r-- | libjava/java/util/TimeZone.java | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/libjava/java/util/TimeZone.java b/libjava/java/util/TimeZone.java index 7c811795790..7b7947f63ca 100644 --- a/libjava/java/util/TimeZone.java +++ b/libjava/java/util/TimeZone.java @@ -1107,15 +1107,21 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable StringBuffer sb = new StringBuffer(9); sb.append("GMT"); - sb.append(offset >= 0 ? '+' : '-'); - offset = Math.abs(offset) / (1000 * 60); - int hours = offset / 60; - int minutes = offset % 60; + offset = offset / (1000 * 60); + int hours = Math.abs(offset) / 60; + int minutes = Math.abs(offset) % 60; + + if (minutes != 0 || hours != 0) + { + sb.append(offset >= 0 ? '+' : '-'); + sb.append((char) ('0' + hours / 10)); + sb.append((char) ('0' + hours % 10)); + sb.append(':'); + sb.append((char) ('0' + minutes / 10)); + sb.append((char) ('0' + minutes % 10)); + } - sb.append((char) ('0' + hours / 10)).append((char) ('0' + hours % 10)); - sb.append(':'); - sb.append((char) ('0' + minutes / 10)).append((char) ('0' + minutes % 10)); return sb.toString(); } |