In most case, how can we justify, when shall we use
NumberFormat.getInstance();
When shall we use
new DecimalForamt(...);
If you want to specify how your numbers are formatted, then you must use the DecimalFormat constructor. If you want "the way most numbers are represented in my current locale", then use the default instance of NumberFormat.
NumberFormat.getInstance actually gets the formatter based on the locale and number style. It might actually return the DecimalFormat() object. "DecimalFormat is a concrete subclass of NumberFormat that formats decimal numbers" - From JDK javadocs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With