aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2015-02-10 11:11:01 +0100
committeriNPUTmice <daniel@gultsch.de>2015-02-10 11:11:01 +0100
commit6c8b82dd663b3183b1769891daf11edfa46ded5d (patch)
treee5218864d17957de0a6fe9d158217fb3ba9442f9 /src/main/java
parentd1076588f42aaafbcd75ca36f34b2f53c5765134 (diff)
strip fractional seconds from timestamp before parsing
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java2
-rw-r--r--src/main/java/eu/siacs/conversations/parser/AbstractParser.java8
2 files changed, 4 insertions, 6 deletions
diff --git a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java
index 526e5b19..7e745443 100644
--- a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java
+++ b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java
@@ -33,7 +33,7 @@ public abstract class AbstractGenerator {
public final String IDENTITY_NAME = "Conversations 1.0";
public final String IDENTITY_TYPE = "phone";
- private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
+ private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
protected XmppConnectionService mXmppConnectionService;
diff --git a/src/main/java/eu/siacs/conversations/parser/AbstractParser.java b/src/main/java/eu/siacs/conversations/parser/AbstractParser.java
index 391a2d0d..3f7f1548 100644
--- a/src/main/java/eu/siacs/conversations/parser/AbstractParser.java
+++ b/src/main/java/eu/siacs/conversations/parser/AbstractParser.java
@@ -1,5 +1,6 @@
package eu.siacs.conversations.parser;
+
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -40,11 +41,8 @@ public abstract class AbstractParser {
public static Date parseTimestamp(String timestamp) throws ParseException {
timestamp = timestamp.replace("Z", "+0000");
SimpleDateFormat dateFormat;
- if (timestamp.contains(".")) {
- dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ", Locale.US);
- } else {
- dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ",Locale.US);
- }
+ 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);
}