🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › text › spi › NumberFormatProvider.html
NumberFormatProvider (Java SE 21 & JDK 21)
October 20, 2025 - Returns a new NumberFormat instance which formats a number in its compact form for the specified locale and formatStyle.
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › text › NumberFormat.html
NumberFormat (Java SE 21 & JDK 21)
January 20, 2026 - The default implementation provides ... mode use setRoundingMode. The NumberFormat returned by the static factory methods is configured to round floating point numbers using half-even rounding (see RoundingMode.HALF_EVEN) for formatting....
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › text › class-use › NumberFormat.html
Uses of Class java.text.NumberFormat (Java SE 21 & JDK 21)
October 20, 2025 - Returns a new NumberFormat instance which formats percentage values for the specified locale. Constructors in javax.swing.text with parameters of type NumberFormat
🌐
GeeksforGeeks
geeksforgeeks.org › java › numberformat-class-java
NumberFormat Class in Java - GeeksforGeeks
January 23, 2026 - NumberFormat.getInstance() returns a NumberFormat object for the system’s default locale. nf.format(1234567.89) converts the numeric value into a locale-specific formatted string.
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › text › NumberFormat.Style.html
NumberFormat.Style (Java SE 21 & JDK 21)
October 20, 2025 - Style is an enum which represents the style for formatting a number within a given NumberFormat instance.
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › text › DecimalFormat.html
DecimalFormat (Java SE 21 & JDK 21)
January 20, 2026 - DecimalFormat is a concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features designed to make it possible to parse and format numbers in any locale, including support for Western, Arabic, and Indic digits. It also supports different kinds of numbers, including ...
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.text.numberformat
NumberFormat Class (Java.Text) | Microsoft Learn
You can also use a NumberFormat to parse numbers: <blockquote> ... </blockquote> Use getInstance or getNumberInstance to get the normal number format. Use getIntegerInstance to get an integer number format.
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.desktop › javax › swing › text › NumberFormatter.html
NumberFormatter (Java SE 21 & JDK 21)
January 20, 2026 - The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see XMLEncoder. ... Creates a NumberFormatter with the default NumberFormat instance obtained from NumberFormat.getNumberInstance().
🌐
GitHub
github.com › jdemetra › jdemetra-core › issues › 421
NumberFormat produces different code point after Java 13 build 21 · Issue #421 · jdemetra/jdemetra-core
March 16, 2019 - According to this JDK issue, the grouping separator for French numbers has been changed from U+00A0 to U+202F in Java13+. The direct consequence is that a file containing these formatted numbers mi...
Author   charphi
Find elsewhere
🌐
Javaplanet
javaplanet.io › home › java.text › numberformat
NumberFormat -
September 12, 2025 - Use NumberFormat to make the financial figures user-friendly and localized. import java.text.NumberFormat; import java.util.Locale; class LoanDetails { String customerName; double loanAmount; double interestRate; // in decimal, e.g., 0.075 for 7.5% double emi; public LoanDetails(String customerName, double loanAmount, double interestRate, double emi) { this.customerName = customerName; this.loanAmount = loanAmount; this.interestRate = interestRate; this.emi = emi; } } public class LoanEMISummary { public static void main(String[] args) { LoanDetails[] customers = { new LoanDetails("Mahesh", 50
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › text › NumberFormat.html
NumberFormat (Java Platform SE 8 )
1 week ago - Java™ Platform Standard Ed. 8 ... NumberFormat is the abstract base class for all number formats. This class provides the interface for formatting and parsing numbers.
🌐
Reddit
reddit.com › r/java › what was the thought process behind the design of the numberformat class? why doesn't it have a way to set a pattern?
r/java on Reddit: What was the thought process behind the design of the NumberFormat class? Why doesn't it have a way to set a pattern?
June 2, 2024 -

I know that the sub class DecimalFormat has a way to set the pattern, but it instead doesn't have a way to set the locale.

So, if you want to set both the locale and the pattern, you have to use one of the getInstance methods of the NumberFormat class, and then cast the result to a DecimalFormat in order to call the applyPattern method.

But the getInstance methods of NumberFormat doesn't guarantee which subclass you will get. Even if the code works now, it might break in the future.

What were they thinking when they designed these classes? Or is my use case here really an anomality?

Edit: I found a proper way of handling this, using the alternative constructor:

DecimalFormat decimalFormat = new DecimalFormat("#,##0.00", DecimalFormatSymbols.getInstance(Locale.US));
🌐
OpenJDK
cr.openjdk.org › ~jlaskey › java.base › java › text › NumberFormat.Style.html
NumberFormat.Style (Java SE 21 & JDK 21 [ad-hoc build])
Style is an enum which represents the style for formatting a number within a given NumberFormat instance.
🌐
OpenJDK
cr.openjdk.org › ~pminborg › panama › 21 › v1 › javadoc › java.base › java › text › CompactNumberFormat.html
CompactNumberFormat (Java SE 21 [ad-hoc build])
February 9, 2022 - Creates a CompactNumberFormat using the given decimal pattern, decimal format symbols, compact patterns, and plural rules. To obtain the instance of CompactNumberFormat with the standard compact patterns for a Locale, Style, and pluralRules, it is recommended to use the factory methods given ...