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_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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue