I want to format a certain time/date,(HH:mm) to a specific locale type. For example, I have 12:05 and I need it to be - in french 12h05 - in dutch 12u05
Is this possible without checking the current locale and adjust the result?
fun String.hourFormat() : String {
val time = LocalTime.parse (this, DateTimeFormatter.ISO_DATE_TIME)
val result = DateTimeFormatter.ofPattern("HH:mm").withLocale(LocaleManager.currentLocale())
return result
}
Does there exist something already implemented to format the time based on locale? The current approach for me is to manually check the locale :
fun String.hourFormat() : String {
....
val localePattern = when (LocaleManager.currentLocale().name){
"FR" -> "HH'h'mm"
"NL" -> "HH'u'mm"
}
DateTimeFormatter.ofPattern(localePattern)
}