From e3b7f167ff00c9842dd6a30f304d813022a7f10b Mon Sep 17 00:00:00 2001 From: Yihong Gao Date: Sat, 15 Aug 2020 14:35:10 -0700 Subject: [PATCH] Fix date format of some Asian languages (#1928) With DateFormat.getBestDateTimePattern to generate best localized pattern. Signed-off-by: Yihong Gao --- CHANGES.md | 1 + .../main/java/im/vector/app/core/date/VectorDateFormatter.kt | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 54a0194a6d..1a6d2b95a5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,7 @@ Improvements 🙌: - Ensure users do not accidentally ignore other users (#1890) Bugfix 🐛: + - Fix incorrect date format for some Asian languages (#1928) - Fix invisible toolbar (Status.im theme) (#1746) - Fix relative date time formatting (#822) - Fix crash reported by RageShake diff --git a/vector/src/main/java/im/vector/app/core/date/VectorDateFormatter.kt b/vector/src/main/java/im/vector/app/core/date/VectorDateFormatter.kt index 1b92511104..02050b0a56 100644 --- a/vector/src/main/java/im/vector/app/core/date/VectorDateFormatter.kt +++ b/vector/src/main/java/im/vector/app/core/date/VectorDateFormatter.kt @@ -17,6 +17,7 @@ package im.vector.app.core.date import android.content.Context +import android.text.format.DateFormat import android.text.format.DateUtils import im.vector.app.core.resources.LocaleProvider import org.threeten.bp.LocalDateTime @@ -45,8 +46,9 @@ class VectorDateFormatter @Inject constructor(private val context: Context, private val messageHourFormatter by lazy { DateTimeFormatter.ofPattern("H:mm", localeProvider.current()) } + private val messageDayFormatter by lazy { - DateTimeFormatter.ofPattern("EEE d MMM", localeProvider.current()) + DateTimeFormatter.ofPattern(DateFormat.getBestDateTimePattern(localeProvider.current(), "EEE d MMM")) } fun formatMessageHour(localDateTime: LocalDateTime): String {