Android Programming The Big Nerd Ranch Guide by Bill Phillips, Chris Stewart, Kristin Marsicano (z-lib.org)

(gtxtreme123) #1

Chapter 18  Localization


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.

Free download pdf