I read this article: JDK 8 and JRE 8 Supported Locales, it stated that:
Numbering systems can be specified by a language tag with a numbering system ID
╔═════════════════════╦══════════════════════╦══════════════════╗ ║ Numbering System ID ║ Numbering System ║ Digit Zero Value ║ ╠═════════════════════╬══════════════════════╬══════════════════╣ ║ arab ║ Arabic-Indic Digits ║ \u0660 ║ ╚═════════════════════╩══════════════════════╩══════════════════╝
Now, to demonstrate this, I wrote the following codes:
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.util.Locale;
public class Main
{
public static void main(String[] args)
{
Locale locale = new Locale("ar", "sa", "arab");
DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(locale);
NumberFormat numberFormat = NumberFormat.getNumberInstance(locale);
System.out.println(dfs.getZeroDigit());
System.out.println(numberFormat.format(123));
}
}
I was expecting the output to be something like:
٠
١٢٣
However, the output is as follows:
0
123
The main purpose of this is to make JavaFX GUI showing Arabic numbers instead of English numbers as it uses the default locale (and I can set it with Locale.setDefault(...)
).
So my question is, how to use the numbering system in the locale to show localized numbers in Java? Then, is it possible to apply it on JavaFX?