diff --git a/res/layout/message_details_header.xml b/res/layout/message_details_header.xml index 5676efe17d..39e7d55ed2 100644 --- a/res/layout/message_details_header.xml +++ b/res/layout/message_details_header.xml @@ -34,7 +34,8 @@ + android:layout_height="match_parent" + android:shrinkColumns="1"> + tools:text="Jan 18, 2015, 12:29:37 AM GMT-08:00" /> @@ -70,7 +71,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/message_details_table_row_pad" - tools:text="Jan 18, 9:31AM" /> + tools:text="Jan 18, 2015, 12:31:15 AM GMT-08:00" /> diff --git a/src/org/thoughtcrime/securesms/util/DateUtils.java b/src/org/thoughtcrime/securesms/util/DateUtils.java index ac570fd80d..35bc2557f1 100644 --- a/src/org/thoughtcrime/securesms/util/DateUtils.java +++ b/src/org/thoughtcrime/securesms/util/DateUtils.java @@ -17,6 +17,7 @@ package org.thoughtcrime.securesms.util; import android.content.Context; +import android.os.Build; import android.text.format.DateFormat; import java.text.SimpleDateFormat; @@ -41,7 +42,7 @@ public class DateUtils extends android.text.format.DateUtils { } private static String getFormattedDateTime(long time, String template, Locale locale) { - String localizedPattern = new SimpleDateFormat(template, locale).toLocalizedPattern(); + final String localizedPattern = getLocalizedPattern(template, locale); return new SimpleDateFormat(localizedPattern, locale).format(new Date(time)); } @@ -86,12 +87,19 @@ public class DateUtils extends android.text.format.DateUtils { String dateFormatPattern; if (DateFormat.is24HourFormat(context)) { - dateFormatPattern = "MMM d, yyyy HH:mm:ss zzz"; + dateFormatPattern = getLocalizedPattern("MMM d, yyyy HH:mm:ss zzz", locale); } else { - dateFormatPattern = "MMM d, yyyy hh:mm:ss a zzz"; + dateFormatPattern = getLocalizedPattern("MMM d, yyyy hh:mm:ss a zzz", locale); } return new SimpleDateFormat(dateFormatPattern, locale); } + private static String getLocalizedPattern(String template, Locale locale) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { + return DateFormat.getBestDateTimePattern(locale, template); + } else { + return new SimpleDateFormat(template, locale).toLocalizedPattern(); + } + } }