import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Locale;
publicclass Main {
publicstaticvoid main(String[] args) {
formatDouble(newDouble("345.9372"));
}/*fromwww.java2s.com*/publicstaticvoid formatDouble(double myDouble) {
NumberFormat numberFormatter = newDecimalFormat("##.000");
String result = numberFormatter.format(myDouble);
System.out.println(result);
// Obtains an instance of NumberFormat classNumberFormat format = NumberFormat.getInstance();
// Format a double value for the current localeString result2 = format.format(76543.404);
System.out.println(result2);
// Format a double value for an Italian locale
result = NumberFormat.getInstance(Locale.ITALIAN).format(65432.404);
System.out.println(result2);
}
}