java.text.DecimalFormat format = new java.text.DecimalFormat("0.000");
String s = format.format(1.24);
System.out.println(s);