aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/xmpp/extensions
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/xmpp/extensions')
-rw-r--r--src/main/java/com/juick/xmpp/extensions/JuickMessage.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/main/java/com/juick/xmpp/extensions/JuickMessage.java b/src/main/java/com/juick/xmpp/extensions/JuickMessage.java
index 53dd6deb..bbc1568e 100644
--- a/src/main/java/com/juick/xmpp/extensions/JuickMessage.java
+++ b/src/main/java/com/juick/xmpp/extensions/JuickMessage.java
@@ -20,6 +20,10 @@ package com.juick.xmpp.extensions;
import com.juick.xmpp.utils.XmlUtils;
import com.juick.xmpp.*;
import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.TimeZone;
+
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -32,7 +36,11 @@ public class JuickMessage extends com.juick.Message implements StanzaChild {
public final static String XMLNS = "http://juick.com/message";
public final static String TagName = "juick";
+ private SimpleDateFormat df;
+
public JuickMessage() {
+ df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ df.setTimeZone(TimeZone.getTimeZone("UTC"));
}
public JuickMessage(com.juick.Message msg) {
@@ -45,7 +53,7 @@ public class JuickMessage extends com.juick.Message implements StanzaChild {
}
@Override
- public JuickMessage parse(XmlPullParser parser) throws XmlPullParserException, IOException {
+ public JuickMessage parse(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
JuickMessage jmsg = new JuickMessage();
final String sMID = parser.getAttributeValue(null, "mid");
@@ -72,7 +80,8 @@ public class JuickMessage extends com.juick.Message implements StanzaChild {
if (sReadOnly != null) {
jmsg.ReadOnly = true;
}
- jmsg.TimestampString = parser.getAttributeValue(null, "ts");
+
+ jmsg.setDate(df.parse(parser.getAttributeValue(null, "ts")));
jmsg.AttachmentType = parser.getAttributeValue(null, "attach");
while (parser.next() == XmlPullParser.START_TAG) {
@@ -112,8 +121,8 @@ public class JuickMessage extends com.juick.Message implements StanzaChild {
if (ReadOnly) {
ret += " readonly=\"1\"";
}
- if (TimestampString != null) {
- ret += " ts=\"" + TimestampString + "\"";
+ if (getDate() != null) {
+ ret += " ts=\"" + df.format(getDate()) + "\"";
}
if (AttachmentType != null) {
ret += " attach=\"" + AttachmentType + "\"";
@@ -126,8 +135,8 @@ public class JuickMessage extends com.juick.Message implements StanzaChild {
ret += "<body>" + XmlUtils.escape(getText()) + "</body>";
}
if (!Tags.isEmpty()) {
- for (int i = 0; i < Tags.size(); i++) {
- ret += "<tag>" + XmlUtils.escape(Tags.get(i)) + "</tag>";
+ for (String Tag : Tags) {
+ ret += "<tag>" + XmlUtils.escape(Tag) + "</tag>";
}
}
ret += "</" + TagName + ">";