In this example, we’re setting min and max digits for both integer as well as fractional part of a number.

Open Compiler

importjava.text.NumberFormat;importjava.util.Locale;publicclassI18NTester{publicstaticvoidmain(String[] args){Locale enLocale =newLocale("en","US");NumberFormat numberFormat =NumberFormat.getInstance(enLocale);
      numberFormat.setMinimumIntegerDigits(2);
      numberFormat.setMaximumIntegerDigits(3);

      numberFormat.setMinimumFractionDigits(2);
      numberFormat.setMaximumFractionDigits(3);System.out.println(numberFormat.format(12234.763443));}}

Output

It will print the following result.

234.763

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *