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