Format a number using the current Locale() in Java

Description

The following code shows how to format a number using the current Locale().

Example


/* w w  w .ja  v a 2  s  . c  o m*/
import java.text.NumberFormat;
import java.util.Locale;

public class Main {
  public static void main(String[] args) throws Exception {
   System.out.println(NumberFormat.getInstance(new Locale("us")).format(12345.12345)); 

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Data Format »




Java Formatter
Java Number Formatter