NumberFormat: getNumberInstance() : NumberFormat « java.text « Java by API






NumberFormat: getNumberInstance()

 

/*Output: 
 * User's number (DEFAULT LOCALE): 1,976.083
 * */


import java.text.NumberFormat;

public class MainClass {
  public static void main(String args[]) throws Exception {
    NumberFormat numberFormat = NumberFormat.getInstance();
    numberFormat.setParseIntegerOnly(false);
    double usersNumber = 1976.0826;

    numberFormat = NumberFormat.getNumberInstance();
    System.out.println("User's number (DEFAULT LOCALE): " + numberFormat.format(usersNumber));
    
  }
}

           
         
  








Related examples in the same category

1.NumberFormat: format(Object obj)
2.NumberFormat.getCurrencyInstance();
3.NumberFormat: getCurrencyInstance(Locale.UK)
4.NumberFormat: getInstance()
5.NumberFormat: getNumberInstance(Locale.FRENCH)
6.NumberFormat: getIntegerInstance(Locale.ITALIAN)
7.NumberFormat: getNumberInstance(Locale inLocale)
8.NumberFormat: getPercentInstance(Locale inLocale)
9.NumberFormat: parse(String source)
10.NumberFormat.setMaximumFractionDigits(int newValue)
11.NumberFormat: setMinimumFractionDigits(int newValue)
12.NumberFormat: setMinimumIntegerDigits(int newValue)
13.NumberFormat: setParseIntegerOnly(boolean value)