//The number we want to show. double dbl = 10000.0 / 3.0;
//Get a Locale object from the java.util package. java.util.Locale locale = java.util.Locale.getDefault();
//Format the number for a given Locale. java.text.NumberFormat nf = java.text.NumberFormat.getNumberInstance(locale.US); java.lang.String strUSnum = nf.format(dbl);
//Format the number as Locale currency. java.text.NumberFormat cf = java.text.NumberFormat.getCurrencyInstance(locale.US); java.lang.String strUSD = cf.format(dbl);
//Format the number with a custom format. java.text.DecimalFormat df = new java.text.DecimalFormat(",##0.000000 foobars"); java.lang.String strCustomNum = df.format(dbl);
java.lang.System.out.println(strUSnum); java.lang.System.out.println(strUSD); java.lang.System.out.println(strCustomNum);