strip fractional seconds from timestamp before parsing
This commit is contained in:
parent
d1076588f4
commit
6c8b82dd66
|
@ -33,7 +33,7 @@ public abstract class AbstractGenerator {
|
||||||
public final String IDENTITY_NAME = "Conversations 1.0";
|
public final String IDENTITY_NAME = "Conversations 1.0";
|
||||||
public final String IDENTITY_TYPE = "phone";
|
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;
|
protected XmppConnectionService mXmppConnectionService;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.siacs.conversations.parser;
|
package eu.siacs.conversations.parser;
|
||||||
|
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -40,11 +41,8 @@ public abstract class AbstractParser {
|
||||||
public static Date parseTimestamp(String timestamp) throws ParseException {
|
public static Date parseTimestamp(String timestamp) throws ParseException {
|
||||||
timestamp = timestamp.replace("Z", "+0000");
|
timestamp = timestamp.replace("Z", "+0000");
|
||||||
SimpleDateFormat dateFormat;
|
SimpleDateFormat dateFormat;
|
||||||
if (timestamp.contains(".")) {
|
timestamp = timestamp.substring(0,19)+timestamp.substring(timestamp.length() -5,timestamp.length());
|
||||||
dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ", Locale.US);
|
dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ",Locale.US);
|
||||||
} else {
|
|
||||||
dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ",Locale.US);
|
|
||||||
}
|
|
||||||
return dateFormat.parse(timestamp);
|
return dateFormat.parse(timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue