diff options
Diffstat (limited to 'src/main/java/eu/siacs/conversations')
-rw-r--r-- | src/main/java/eu/siacs/conversations/parser/AbstractParser.java | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/parser/AbstractParser.java b/src/main/java/eu/siacs/conversations/parser/AbstractParser.java index 977062e2..473195bd 100644 --- a/src/main/java/eu/siacs/conversations/parser/AbstractParser.java +++ b/src/main/java/eu/siacs/conversations/parser/AbstractParser.java @@ -1,5 +1,7 @@ package eu.siacs.conversations.parser; +import android.util.Log; + import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; @@ -41,8 +43,14 @@ public abstract class AbstractParser { if (stamp == null) { return now; } - long time = parseTimestamp(stamp).getTime(); - return now < time ? now : time; + /*long time = parseTimestamp(stamp).getTime(); + return now < time ? now : time;*/ + try { + long time = parseTimestamp(stamp).getTime(); + return now < time ? now : time; + } catch (ParseException e) { + return now; + } } /** @@ -53,12 +61,19 @@ public abstract class AbstractParser { * @return Date * @throws ParseException */ - public static Date parseTimestamp(String timestamp) { - try { + public static Date parseTimestamp(String timestamp) throws ParseException { + /*try { + Log.d("TIMESTAMP", timestamp); return DatatypeFactory.newInstance().newXMLGregorianCalendar(timestamp).toGregorianCalendar().getTime(); } catch (DatatypeConfigurationException e) { + Log.d("TIMESTAMP", e.getMessage()); return new Date(); - } + }*/ + timestamp = timestamp.replace("Z", "+0000"); + SimpleDateFormat dateFormat; + timestamp = timestamp.substring(0,19)+timestamp.substring(timestamp.length() -5,timestamp.length()); + dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ",Locale.US); + return dateFormat.parse(timestamp); } protected void updateLastseen(final Element packet, final Account account, |