NumberFormat Class in Java Last Updated : 09 Feb, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report NumberFormat is an abstract base class for all number formats. This class provides the interface for formatting and parsing numbers. NumberFormat also provides methods for determining which locales (US, India, Italy, etc.) have number formats and their names. NumberFormat helps you to format and parse numbers for any locale. Example: Suppose we have a double type number. But this double type number is represented in different ways in different countries. To represent a number according to various countries, we have to take the help of NumberFormat class like: double d = 123456.789; For India, it is represented like 1,23,456.789 For US, it is represented like 123,456.789 For ITALY, it is represented like 123.456,789 Some Important Points About NumberFormat Class: NumberFormat class is present in java.text package, and it is an abstract class.NumberFormat class implements Serializable, Cloneable.NumberFormat is the direct child class of Format class.Number formats are generally not synchronized. It is recommended to create separate format instances for each thread. If multiple threads access a format concurrently, it must be synchronized externally.Methods Present in NumberFormat ClassS. No.MethodDescription1.public static NumberFormat getInstance()To get the NumberFormat object for default Locale.2.public static NumberFormat getCurrencyInstance()To get the NumberFormat object for default Locale to represent in specific Currency.3.public static NumberFormat getPercentInstance()The function accepts a single mandatory parameter inLocale which describes the locale which is to be specified.4.public static NumberFormat getInstance(Locale l)To get the NumberFormat object for the specified Locale object.5.public static format(long l)To convert java number to locale object. Example: Java // Java Program to illustrate NumberFormat class use import java.text.*; import java.util.*; class NumberFormatDemo { public static void main(String[] args) { double d = 123456.789; NumberFormat nf = NumberFormat.getInstance(Locale.ITALY); System.out.println("ITALY representation of " + d + " : " + nf.format(d)); } } OutputITALY representation of 123456.789 : 123.456,789 Comment More infoAdvertise with us Next Article Java Math Class B bishaldubey Follow Improve Article Tags : Misc Java Java-Data Types Practice Tags : JavaMisc Similar Reads Java.lang.Number Class in Java Most of the time, while working with numbers in java, we use primitive data types. But, Java also provides various numeric wrapper sub classes under the abstract class Number present in java.lang package. There are mainly six sub-classes under Number class.These sub-classes define some useful method 9 min read Java Math Class Java.lang.Math Class methods help to perform numeric operations like square, square root, cube, cube root, exponential and trigonometric operations.Declarationpublic final class Math extends Object Methods of Math Class in JavaMath class consists of methods that can perform mathematical operations a 7 min read NumberFormat parse() method in Java with Examples The parse(str) method is a built-in method of the java.text.NumberFormat which parses text from the beginning of the given string to produce a number. The method may not use the entire text of the given string Syntax: public Number parse?(String str) Parameters: The function accepts a string str who 2 min read NumberFormat hashCode() method in Java with Examples The hashCode() method is a built-in method of the java.text.NumberFormat returns a hash-code value for this given object of instance. Syntax: public int hashCode() Parameters: The function does not accepts any parameter. Return Value: The function returns the hash-code value. Below is the implementa 1 min read Basic Operators in Java Java provides a rich operator environment. We can classify the basic operators in java in the following groups: Arithmetic OperatorsRelational OperatorsBitwise OperatorsAssignment OperatorsLogical Operators Let us now learn about each of these operators in detail. 1. Arithmetic Operators: Arithmetic 10 min read NumberFormat getInstance() method in Java with Examples The getInstance() method is a built-in method of the java.text.NumberFormat returns a number format for the current default FORMAT locale. Syntax: public static final NumberFormat getInstance() Parameters: The function does not accepts any parameter. Return Value: The function returns the NumberForm 2 min read Like