From 69085ee09604948612886aca9c36fcf1c15e5452 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 21 Sep 2023 19:03:51 +0200 Subject: [PATCH] Fixed skeleton date/time format --- app/src/main/java/eu/faircode/email/Helper.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index 1beb0405b6..59ce90bb4f 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -2171,9 +2171,17 @@ public class Helper { boolean thisMonth = (cal0.get(Calendar.MONTH) == cal1.get(Calendar.MONTH)); boolean thisDay = (cal0.get(Calendar.DAY_OF_MONTH) == cal1.get(Calendar.DAY_OF_MONTH)); if (withDate) { - String skeleton = (thisMonth && thisYear ? "MMM-d" : "Y-M-d") + (withTime ? " Hm" : ""); - String format = android.text.format.DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton); - return new SimpleDateFormat(format).format(millis); + try { + String skeleton = (thisMonth && thisYear ? "MMM-d" : "yyyy-M-d") + (withTime ? " Hm" : ""); + String format = android.text.format.DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton); + return new SimpleDateFormat(format).format(millis); + } catch (Throwable ex) { + Log.e(ex); + if (withTime) + return getDateTimeInstance(context).format(millis); + else + return getDateInstance(context).format(millis); + } } else if (thisYear && thisMonth && thisDay) return getTimeInstance(context, SimpleDateFormat.SHORT).format(millis); else