From b44f0d270d1a27e68515a84e1974471d7a4e3f9a Mon Sep 17 00:00:00 2001 From: mttronc Date: Tue, 30 Jan 2018 20:17:12 +0100 Subject: [PATCH] Fix times in message list The Date object stores a UTC timestamp. It will automatically be converted to the correct local time. Fixes #27 --- app/src/main/java/io/Pushjet/api/PushListAdapter.java | 2 +- .../main/java/io/Pushjet/api/PushjetApi/PushjetMessage.java | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/app/src/main/java/io/Pushjet/api/PushListAdapter.java b/app/src/main/java/io/Pushjet/api/PushListAdapter.java index 92fe56d5..668a025e 100644 --- a/app/src/main/java/io/Pushjet/api/PushListAdapter.java +++ b/app/src/main/java/io/Pushjet/api/PushListAdapter.java @@ -70,7 +70,7 @@ public View getView(int position, View convertView, ViewGroup parent) { if (title.equals("")) title = entries.get(position).getService().getName(); String description = entries.get(position).getMessage(); - Date pushDate = entries.get(position).getLocalTimestamp(); + Date pushDate = entries.get(position).getTimestamp(); Bitmap icon = entries.get(position).getService().getIconBitmapOrDefault(context); dateText.setText(this.df.format(pushDate)); diff --git a/app/src/main/java/io/Pushjet/api/PushjetApi/PushjetMessage.java b/app/src/main/java/io/Pushjet/api/PushjetApi/PushjetMessage.java index bdc38674..187fe2e8 100644 --- a/app/src/main/java/io/Pushjet/api/PushjetApi/PushjetMessage.java +++ b/app/src/main/java/io/Pushjet/api/PushjetApi/PushjetMessage.java @@ -77,10 +77,6 @@ public void setTimestamp(Date timestamp) { this.timestamp = timestamp; } - public Date getLocalTimestamp() { - return new Date(timestamp.getTime() + TimeZone.getDefault().getOffset(System.currentTimeMillis())); - } - public String getTitleOrName() { String ret = title; if (ret.equals(""))