Formatting and Parsing Locale-Specific Currency : NumberFormat « I18N « Java Tutorial






import java.text.NumberFormat;
import java.util.Locale;

public class Main {
  public static void main(String[] argv) throws Exception {
    // Format
    Locale locale = Locale.GERMANY;
    String string = NumberFormat.getCurrencyInstance(locale).format(123.45);

  }
}
// 123,45 DM








13.14.NumberFormat
13.14.1.Format for GERMAN locale
13.14.2.Format for the default locale
13.14.3.Parse a GERMAN number
13.14.4.Formatting a Number in Exponential Notation
13.14.5.Using only 0's to the left of E forces no decimal point
13.14.6.Formatting and Parsing Locale-Specific Currency
13.14.7.Parse number with NumberFormat and Locale
13.14.8.Formatting and Parsing a Locale-Specific Percentage
13.14.9.Parse a number with NumberFormat and Locale.CANADA
13.14.10.Format a number with DecimalFormat
13.14.11.Parse a number for a locale
13.14.12.Format a number for a locale
13.14.13.Use java.text.NumberFormat to format a currency value.
13.14.14.Use grouping to display a number
13.14.15.Set format to two decimal places