November 2004
Intermediate to advanced
1024 pages
27h 50m
English
When you are formatting date and time, you should be concerned with four locale-dependent issues:
The names of months and weekdays should be presented in the local language.
There will be local preferences for the order of year, month, and day.
The Gregorian calendar may not be the local preference for expressing dates.
The time zone of the location must be taken into account.
The Java DateFormat class handles these issues. It is easy to use and quite similar to the NumberFormat class. First, you get a locale. You can use the default locale or call the static getAvailableLocales method to obtain an array of locales that support date formatting. Then, you call one of the three factory methods:
fmt = DateFormat.getDateInstance(dateStyle, ...
Read now
Unlock full access