Reputation: 7501
I've upgraded to Java 8 recently and ran into an "issue" with formatting a date. JDK 8 allows providers to be used for certain g11n/i18n functions, and if you have ICU on the classpath it should pick that up. This isn't really an issue as much as an unexpected curve, with most of my functions working as previous.
I'd like to display todays date, but with a locale's date format, decimal separator, etc. This goes well and good, however when I use certain locales that have a different numeral set, such as ar_OM, which uses a Hindu-Arabic Numeral System, I get the date formatted, but with the numbers in this numeral system as well.
Code:
Locale arOmLocale = new Locale("ar", "OM");
DateFormat df = DateFormat.getDateInstance(DateFormat.DEFAULT, arOmLocale);
System.out.println(df.format(new Date()));
I would like to see it print out 2015/04/11, however it prints out ١١/٠٤/٢٠١٥
Is there a way to have it not change the digit system/symbols, but still provide formatting that is specific to the locale?
Upvotes: 0
Views: 264
Reputation: 7501
There is an ICU4j specific fix, and that is using the @numbers=latn
as a variant/script on the locale.
Some details are laid out here: Formatting for a Locale
Upvotes: 0