Example
In this example, we’re showcasing parsing of number present in different locale.
Open Compiler
importjava.text.NumberFormat;importjava.text.ParseException;importjava.util.Locale;publicclassI18NTester{publicstaticvoidmain(String[] args)throwsParseException{Locale enLocale =newLocale("en","US");Locale daLocale =newLocale("da","DK");NumberFormat numberFormat =NumberFormat.getInstance(daLocale);System.out.println(numberFormat.parse("100,76"));
numberFormat =NumberFormat.getInstance(enLocale);System.out.println(numberFormat.parse("100,76"));}}
Output
It will print the following result.
100.76
10076
Leave a Reply