[Android] Use user's locale time format for TV

Nicolas Pomepuy git at videolan.org
Mon Jul 29 14:08:44 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Mon Jul 29 07:22:59 2019 +0200| [ea8df450fd84fe91d13dc5d67b40393fa9e7a03c] | committer: Nicolas Pomepuy

Use user's locale time format for TV

> https://code.videolan.org/videolan/vlc-android/commit/ea8df450fd84fe91d13dc5d67b40393fa9e7a03c
---

 vlc-android/src/org/videolan/vlc/gui/tv/TimeUpdater.kt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/TimeUpdater.kt b/vlc-android/src/org/videolan/vlc/gui/tv/TimeUpdater.kt
index 0da85a021..f1d312362 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/TimeUpdater.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/TimeUpdater.kt
@@ -30,6 +30,7 @@ import androidx.fragment.app.FragmentActivity
 import androidx.lifecycle.Lifecycle
 import androidx.lifecycle.LifecycleObserver
 import androidx.lifecycle.OnLifecycleEvent
+import java.text.DateFormat
 import java.util.*
 
 private const val TAG = "VLC/TimeUpdater"
@@ -37,8 +38,9 @@ private const val TAG = "VLC/TimeUpdater"
 class TimeUpdater(private val activity: Activity, private val tv: TextView) : LifecycleObserver {
 
     private fun updateTime() {
-        val calendar = Calendar.getInstance()
-        tv.text = String.format("%d:%02d", calendar[Calendar.HOUR_OF_DAY], calendar[Calendar.MINUTE])
+
+        val format = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.getDefault())
+        tv.text = format.format(Date())
     }
 
     @OnLifecycleEvent(Lifecycle.Event.ON_START)



More information about the Android mailing list