aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-03-11 17:22:50 +0100
committerChristian Schneppe <christian@pix-art.de>2017-03-11 20:14:57 +0100
commit36d6885162566e2b3041d470b45fac0206334d01 (patch)
tree4ee8e45a1a5495496d811937c09897083cf0b0fe /src/main
parentcceac1fb52043e65984ebd4d43880e4c8bab32b6 (diff)
fixed entity time for timezones with minutes !=0
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/pixart/messenger/generator/IqGenerator.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/main/java/de/pixart/messenger/generator/IqGenerator.java b/src/main/java/de/pixart/messenger/generator/IqGenerator.java
index 6658f1a21..e919b437e 100644
--- a/src/main/java/de/pixart/messenger/generator/IqGenerator.java
+++ b/src/main/java/de/pixart/messenger/generator/IqGenerator.java
@@ -15,6 +15,7 @@ import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
import java.util.Set;
import java.util.TimeZone;
import java.util.UUID;
@@ -77,9 +78,16 @@ public class IqGenerator extends AbstractGenerator {
time.addChild("utc").setContent(getTimestamp(now));
TimeZone ourTimezone = TimeZone.getDefault();
long offsetSeconds = ourTimezone.getOffset(now) / 1000;
- long offsetMinutes = offsetSeconds % (60 * 60);
- long offsetHours = offsetSeconds / (60 * 60);
- time.addChild("tzo").setContent(String.format("%02d", offsetHours) + ":" + String.format("%02d", offsetMinutes));
+ long offsetMinutes = Math.abs((offsetSeconds % 3600) / 60);
+ long offsetHours = offsetSeconds / 3600;
+ String hours;
+ if (offsetHours < 0) {
+ hours = String.format(Locale.US, "%03d", offsetHours);
+ } else {
+ hours = String.format(Locale.US, "%02d", offsetHours);
+ }
+ String minutes = String.format(Locale.US, "%02d", offsetMinutes);
+ time.addChild("tzo").setContent(hours + ":" + minutes);
return packet;
}