NumberFormat: setParseIntegerOnly(boolean value)
/*Output:
* User's number (US): 1,976.083
* */
import java.text.NumberFormat;
import java.util.Locale;
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(Locale.US);
System.out.println("User's number (US): " + numberFormat.format(usersNumber));
}
}
Related examples in the same category