From 0571d4b3ed3e510735fda3f11e7b97b8125f82b8 Mon Sep 17 00:00:00 2001 From: Lander Noterman Date: Thu, 20 Aug 2015 10:42:32 +0200 Subject: [PATCH] Also make getConversationTimestamp behave according to locale --- .../com/moez/QKSMS/common/utils/DateFormatter.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/QKSMS/src/main/java/com/moez/QKSMS/common/utils/DateFormatter.java b/QKSMS/src/main/java/com/moez/QKSMS/common/utils/DateFormatter.java index 7418bbfa..49021f78 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/common/utils/DateFormatter.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/common/utils/DateFormatter.java @@ -16,19 +16,15 @@ import java.util.Date; public abstract class DateFormatter { public static String getConversationTimestamp(Context context, long date) { - SimpleDateFormat formatter; - if (isSameDay(date)) { - formatter = accountFor24HourTime(context, new SimpleDateFormat("h:mm a")); + return accountFor24HourTime(context, new SimpleDateFormat("h:mm a")).format(date); } else if (isSameWeek(date)) { - formatter = new SimpleDateFormat("EEE"); + return DateUtils.formatDateTime(context, date, DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_ABBREV_WEEKDAY); } else if (isSameYear(date)) { - formatter = new SimpleDateFormat("MMM d"); + return DateUtils.formatDateTime(context, date, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR | DateUtils.FORMAT_ABBREV_MONTH); } else { - formatter = new SimpleDateFormat("MMM d y"); + return DateUtils.formatDateTime(context, date, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH); } - - return formatter.format(date); } private static boolean isSameDay(long date) {