From 97c5d485f382a81b60c23e5c601c53f480e15577 Mon Sep 17 00:00:00 2001 From: "duojia.xiang" Date: Wed, 14 Oct 2026 12:01:04 +0800 Subject: [PATCH] fix: respect system 24-hour format for message timestamps java.text.DateFormat.getTimeInstance() formats time according to the locale default and ignores the system's 24-hour format setting, so timestamps were shown in 12-hour format on devices with 24-hour format enabled (reported on Samsung One UI 7 / Android 16). Use android.text.format.DateFormat.getTimeFormat()/getDateFormat() instead, which honor the user's system preference. Fixes gotify/android#435 --- .../com/github/gotify/messages/ListMessageAdapter.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/github/gotify/messages/ListMessageAdapter.kt b/app/src/main/kotlin/com/github/gotify/messages/ListMessageAdapter.kt index 1b4dc623..0bfef51e 100644 --- a/app/src/main/kotlin/com/github/gotify/messages/ListMessageAdapter.kt +++ b/app/src/main/kotlin/com/github/gotify/messages/ListMessageAdapter.kt @@ -29,7 +29,6 @@ import com.github.gotify.databinding.MessageItemBinding import com.github.gotify.databinding.MessageItemCompactBinding import com.github.gotify.messages.provider.MessageWithImage import io.noties.markwon.Markwon -import java.text.DateFormat import java.time.OffsetDateTime import java.util.Date @@ -158,9 +157,13 @@ internal class ListMessageAdapter( val time = dateTime.toInstant().toEpochMilli() val date = Date(time) if (DateUtils.isToday(time)) { - DateFormat.getTimeInstance(DateFormat.SHORT).format(date) + android.text.format.DateFormat.getTimeFormat(itemView.context).format(date) } else { - DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(date) + val datePart = android.text.format.DateFormat.getDateFormat(itemView.context) + .format(date) + val timePart = android.text.format.DateFormat.getTimeFormat(itemView.context) + .format(date) + "$datePart $timePart" } }