aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/xmpp/extensions/JuickMessage.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-07-07 11:25:23 +0300
committerGravatar Vitaly Takmazov2016-07-07 11:25:23 +0300
commita93c85c5ea1bf6683f604bef2608053957577ff0 (patch)
treef80998a4cf339a2b85cd5f095f4386de9d46597b /src/main/java/com/juick/xmpp/extensions/JuickMessage.java
parent3e48ba7c9cae9027b0a045aa25ae40b533518865 (diff)
parent857a930d31c425185c9b9405f5a7820e6cec9491 (diff)
merge rebase_all
Diffstat (limited to 'src/main/java/com/juick/xmpp/extensions/JuickMessage.java')
-rw-r--r--src/main/java/com/juick/xmpp/extensions/JuickMessage.java20
1 files changed, 16 insertions, 4 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..885b2375 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;
@@ -31,12 +35,17 @@ 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) {
super(msg);
+ df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ df.setTimeZone(TimeZone.getTimeZone("UTC"));
}
@Override
@@ -45,7 +54,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 +81,10 @@ public class JuickMessage extends com.juick.Message implements StanzaChild {
if (sReadOnly != null) {
jmsg.ReadOnly = true;
}
- jmsg.TimestampString = parser.getAttributeValue(null, "ts");
+ String ts = parser.getAttributeValue(null, "timestamp");
+ if (ts != null) {
+ jmsg.setDate(df.parse(ts));
+ }
jmsg.AttachmentType = parser.getAttributeValue(null, "attach");
while (parser.next() == XmlPullParser.START_TAG) {
@@ -112,8 +124,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 + "\"";