Wednesday 21 October 2020

Force Android DateUtils.getRelativeDateTimeString() to ignore the device locale?

I've found using the android.text.format.DateUtils relative APIs that return values like "yesterday" or "2 hours ago" very nice - but my app does not support every language Android does. So, I default to English, but for every language I don't support, the relative string shows in the device's setting.

For example, like:

Last attempt: hace 11 minutos.

I'd like to make the API call default to English for any languages I don't support. However, I don't see anywhere to set the Locale for the API call - I'm hoping I'm just missing it somewhere.

Is there a way to set the Locale just for the API call, ignoring the device setting?



from Force Android DateUtils.getRelativeDateTimeString() to ignore the device locale?

No comments:

Post a Comment