I can”t get to work a simple code in a fresh project that is suppose to simply write one date in many langage depending on the Locale set.
Locale[] locales = new Locale[] {
Locale.JAPAN,
Locale.CHINA,
Locale.KOREA,
Locale.TAIWAN,
Locale.ITALY,
Locale.FRANCE,
Locale.GERMAN
};
// Get an instance of current date time
Date today = new Date();
//
// Iterates the entire Locale defined above and create a long
// formatted date using the SimpleDateFormat.getDateInstance()
// with the format, the Locale and the date information.
//
for (Locale locale : locales) {
System.out.println("Date format in "
+ locale.getDisplayName()
+ " = "
+ SimpleDateFormat.getDateInstance(
SimpleDateFormat.LONG, locale)
.format(today).toUpperCase());
}
}
Here is the link of this code : URL of the code below
Now here is what it’s suppose to display
Date format in Japanese (Japan) = 2009/01/04
Date format in Chinese (China) = 2009年1月4日
Date format in Korean (South Korea) = 2009년 1월 4일 (일)
Date format in Chinese (Taiwan) = 2009年1月4日
Date format in Italian (Italy) = 4 GENNAIO 2009
Date format in French (France) = 4 JANVIER 2009
Date format in German = 4. JANUAR 2009
And here is MY display :
Date format in Japanese (Japan) = 2012 7 21
Date format in Chinese (China) = 2012 7 21
Date format in Korean (South Korea) = 2012 7 21
Date format in Chinese (Taiwan) = 2012 7 21
Date format in Italian (Italy) = 2012 7 21
Date format in French (France) = 2012 7 21
Date format in German = 2012 7 21
PROBLEM : What’s wrong ? Am I forgeting some obvious thing ? Do you have any lead ?
Thanks.
As it turned out it’s a device-specific problem. The code works on a phone with correct locale data and also on emulator. On HTC Desire there are some ROMs which have locale data corrupted. More on this issue.