Number Format Example Posted on: September 13, 2008 By Deepak Kumar
This Example shows you how to format numbers according to the locale. In the code given below we are formatting number according to the locale
Number Format Example
This Example shows you how to format numbers according to the locale. In the code given below we are
formatting number according to the locale
Methods used in this example are described below :
NumberFormat.getNumberInstance() : NumberFormat class provides the functionality for formatting and parsing numbers. NumberFormat class also provides methods for defining which locales have number formats.
NumberFormat.format() : This method returns a format string of a number.
NumberFormatExample.java
import java.text.*; import java.util.*;
class NumberFormatExample {
public void numberFormat(Locale currentLocale) {
Integer intNum = new Integer(123456789);
Double doubleNum = new Double(1234.1234);
Ask Questions? Discuss: Number Format Example
Post your Comment