aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2015-03-31 16:30:47 +0200
committersteckbrief <steckbrief@chefmail.de>2015-03-31 16:30:47 +0200
commite17b75511e7c9d8206939b742972021c5c9d6b86 (patch)
treec6d8084a40153546a7821f4e5cca9229a14ccaf1 /src/main
parent6220260df3a97a18baf32e3f4d70596cc1eec563 (diff)
timestamp parsing reverted
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/eu/siacs/conversations/parser/AbstractParser.java25
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,