Challenge: Localizing Dates

You may have noticed that, regardless of the device’s locale, the dates displayed in CriminalIntent are always formatted in the default US style, with the month before the day. Take your localization a step further by formatting the dates according to the locale configuration. It is easier than you might think.

Check out the developer documentation on the DateFormat class, which is provided as part of the Android framework. DateFormat provides a date-time formatter that will take into consideration the current locale. You can control the output further by using configuration constants built into DateFormat.

Get Android Programming: The Big Nerd Ranch Guide, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.