Re: String/Number formatting
Code:
import java.text.DecimalFormat;
import java.text.NumberFormat;
public class Util {
public static void main(String[] args) {
double d = 10.45;
NumberFormat formatter = DecimalFormat.getNumberInstance();
formatter.setMaximumFractionDigits(2);
System.out.println(formatter.format(Math.PI));
}
}
Re: String/Number formatting
When the number of more than 999 the formatter seems to put a comma in. How can I set it so that it doesn't do this?
E.g. 1,023.23 should be 1023.23
Re: String/Number formatting
Code:
formatter.setGroupingUsed(false);