The DateFormat
factory methods can take a Locale
as a parameter. The formatter will then parse date strings according to the format for that language/country.
For example:
Locale myLocale = Locale.US;
SimpleDateFormat sdf = SimpleDateFormat.getDateInstance(DateFormat.SHORT, myLocale);
Date d = sdf.parse("03/10/2012");
Will return a date representing the 10th of March 2012. But if myLocale = Locale.UK
, it would represent the 3rd of October 2012.
The various locales can be enumerated by calling DateFormat.getAvailableLocales()
, or the Locale
constructors will take specific language or country codes.