0

I am using an API that gives me a DateTime pattern so I use it and display a date and time according to this pattern. This API is pretty simple, but for the hours it uses "j" symbol, meaning that I should ask system about its hour format and after that display the hours. Java or Android itself don't use this "j" symbols. All their API requires "k,K,h,H" symbols in pattern. Is there a way to ask system which of "k,K,h,H" it uses and then change my "j" symbols to them?

I know that in swift there is DateFormatter class with dateFormat method that returns a localized date format string representing the given date format components arranged appropriately for the specified locale. It can "eat" "j" symbols. Do java or android have something similar?

Ov3r1oad
  • 1,057
  • 1
  • 12
  • 25
  • [`DateTimeFormatter.ofLocalizedTime()`](https://developer.android.com/reference/java/time/format/DateTimeFormatter#ofLocalizedTime(java.time.format.FormatStyle)). For example, on my system `LocalTime.now().format(DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM))` just yielded `15:36:54`. – Ole V.V. May 09 '22 at 13:33
  • See also [my answer here](https://stackoverflow.com/a/54806516/5772882). – Ole V.V. May 09 '22 at 14:20

0 Answers0