aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/generator
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-12-04 16:20:28 +0100
committeriNPUTmice <daniel@gultsch.de>2014-12-10 14:08:06 +0100
commit34558cc2779e5fd3cb8a2afa39be0efcc5314d88 (patch)
tree59e8e5c8b6f3a0fad1b8d779707279f45b399641 /src/main/java/eu/siacs/conversations/generator
parent2b958e51df8655d63b713efa10870c40bdc42856 (diff)
store last message received date in conversation
Diffstat (limited to 'src/main/java/eu/siacs/conversations/generator')
-rw-r--r--src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java
index f46e7ba4..b200b2a1 100644
--- a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java
+++ b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java
@@ -4,9 +4,12 @@ import android.util.Base64;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.Locale;
+import java.util.TimeZone;
import eu.siacs.conversations.services.XmppConnectionService;
@@ -23,6 +26,8 @@ public abstract class AbstractGenerator {
public final String IDENTITY_NAME = "Conversations 0.9.3";
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);
+
protected XmppConnectionService mXmppConnectionService;
protected AbstractGenerator(XmppConnectionService service) {
@@ -46,4 +51,9 @@ public abstract class AbstractGenerator {
byte[] sha1 = md.digest(s.toString().getBytes());
return new String(Base64.encode(sha1, Base64.DEFAULT)).trim();
}
+
+ public static String getTimestamp(long time) {
+ DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
+ return DATE_FORMAT.format(time);
+ }
}