diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-07-16 19:03:14 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-07-16 19:03:14 +0200 |
commit | 670dead69502884d178ab60ec10e8e0e7b7a7915 (patch) | |
tree | 9e34669d5e3425dfc2a148ffd18b8e3ea6b2fead /src/eu/siacs/conversations/parser/AbstractParser.java | |
parent | 6c8997848939a454de2dd3cf5d533fa330ece008 (diff) |
improvements on the dublicate muc messages issue
Diffstat (limited to 'src/eu/siacs/conversations/parser/AbstractParser.java')
-rw-r--r-- | src/eu/siacs/conversations/parser/AbstractParser.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/eu/siacs/conversations/parser/AbstractParser.java b/src/eu/siacs/conversations/parser/AbstractParser.java index f9a7b1c0e..c4c6720aa 100644 --- a/src/eu/siacs/conversations/parser/AbstractParser.java +++ b/src/eu/siacs/conversations/parser/AbstractParser.java @@ -2,6 +2,8 @@ package eu.siacs.conversations.parser; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; import java.util.Date; import java.util.Locale; @@ -20,11 +22,16 @@ public abstract class AbstractParser { protected long getTimestamp(Element packet) { long now = System.currentTimeMillis(); - if (packet.hasChild("delay")) { + ArrayList<String> stamps = new ArrayList<String>(); + for(Element child : packet.getChildren()) { + if (child.getName().equals("delay")) { + stamps.add(child.getAttribute("stamp").replace("Z", "+0000")); + } + } + Collections.sort(stamps); + if (stamps.size() >= 1) { try { - String stamp = packet.findChild("delay").getAttribute( - "stamp"); - stamp = stamp.replace("Z", "+0000"); + String stamp = stamps.get(stamps.size() - 1); if (stamp.contains(".")) { Date date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ",Locale.US) .parse(stamp); |