Example
In this example, we’re showcasing Rounding Mode.
Open Compiler
importjava.math.RoundingMode;importjava.text.NumberFormat;importjava.util.Locale;publicclassI18NTester{publicstaticvoidmain(String[] args){Locale enLocale =newLocale("en","US");NumberFormat numberFormat =NumberFormat.getInstance(enLocale);
numberFormat.setMinimumFractionDigits(0);
numberFormat.setMaximumFractionDigits(0);System.out.println(numberFormat.format(99.50));
numberFormat.setRoundingMode(RoundingMode.HALF_DOWN);System.out.println(numberFormat.format(99.50));}}
Output
It will print the following result.
100
99
Leave a Reply