diff --git a/app/src/main/java/eu/faircode/email/EntityMessage.java b/app/src/main/java/eu/faircode/email/EntityMessage.java index b7018aac25..61f2ef5517 100644 --- a/app/src/main/java/eu/faircode/email/EntityMessage.java +++ b/app/src/main/java/eu/faircode/email/EntityMessage.java @@ -40,7 +40,6 @@ import org.jsoup.nodes.Element; import java.io.File; import java.io.Serializable; import java.text.DateFormat; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -324,12 +323,7 @@ public class EntityMessage implements Serializable { boolean language_detection = prefs.getBoolean("language_detection", false); String l = (language_detection ? language : null); - DateFormat DF; - if (l == null) - DF = Helper.getDateTimeInstance(context); - else - DF = SimpleDateFormat.getDateTimeInstance( - SimpleDateFormat.MEDIUM, SimpleDateFormat.MEDIUM, new Locale(l)); + DateFormat DF = Helper.getDateTimeInstance(context, l == null ? null : new Locale(l)); Element p = document.createElement("p"); if (extended) { diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index 4ea76c5c3b..d00c0b8cbb 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -995,10 +995,18 @@ public class Helper { } static DateFormat getDateTimeInstance(Context context) { - return Helper.getDateTimeInstance(context, SimpleDateFormat.MEDIUM, SimpleDateFormat.MEDIUM); + return getDateTimeInstance(context, null); + } + + static DateFormat getDateTimeInstance(Context context, Locale locale) { + return Helper.getDateTimeInstance(context, SimpleDateFormat.MEDIUM, SimpleDateFormat.MEDIUM, locale); } static DateFormat getDateTimeInstance(Context context, int dateStyle, int timeStyle) { + return getDateTimeInstance(context, dateStyle, timeStyle, null); + } + + static DateFormat getDateTimeInstance(Context context, int dateStyle, int timeStyle, Locale locale) { // TODO fix time format return SimpleDateFormat.getDateTimeInstance(dateStyle, timeStyle); }