There is a slight difference between these two formats. The "#.##" means it will print the number with maximum two decimal places whereas "#.00" means it will always display two decimal places and if the decimal places are less than two, it will replace them with zeros. see the example below with output.

public static final DecimalFormat df1 = new DecimalFormat( "#.##" );
public static final DecimalFormat df2 = new DecimalFormat( "#.00" );

System.out.println(df1.format(7.80));
System.out.println(df1.format(85));
System.out.println(df1.format(85.786));

System.out.println(df2.format(7.80));
System.out.println(df2.format(85));
System.out.println(df2.format(85.786));

And the output will be

7.8
85
85.79

7.80
85.00
85.79
Answer from Raza on Stack Overflow
🌐
Baeldung
baeldung.com › home › java › java numbers › a practical guide to decimalformat
A Practical Guide to DecimalFormat | Baeldung
January 8, 2024 - When the pattern gets applied to a number, its formatting rules are executed, and the result is printed according to the DecimalFormatSymbol of our JVM’s Locale unless a specific Locale is specified.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › text › DecimalFormat.html
DecimalFormat (Java Platform SE 8 )
July 21, 2026 - Java™ Platform Standard Ed. 8 ... 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.
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › text › DecimalFormat.html
DecimalFormat (Java SE 17 & JDK 17)
April 21, 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 ...
🌐
Jenkov
jenkov.com › tutorials › java-internationalization › decimalformat.html
Java DecimalFormat
June 23, 2014 - The java.text.DecimalFormat class is used to format numbers using a formatting pattern you specify yourself.
🌐
Oracle
docs.oracle.com › javase › tutorial › i18n › format › decimalFormat.html
Customizing Formats (The Java™ Tutorials > Internationalization > Formatting)
This class allows you to control the display of leading and trailing zeros, prefixes and suffixes, grouping (thousands) separators, and the decimal separator. If you want to change formatting symbols, such as the decimal separator, you can use the DecimalFormatSymbols in conjunction with the ...
🌐
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 ...
🌐
Medium
medium.com › @AlexanderObregon › formatting-numbers-for-display-with-decimalformat-in-java-0577c0fe0b52
Formatting Numbers for Display with DecimalFormat in Java
June 27, 2025 - But there are a few pieces working together behind the scenes to make that possible. A DecimalFormat pattern is just a string, but that string drives the entire formatting behavior.
Find elsewhere
🌐
Baeldung
baeldung.com › home › java › java numbers › number formatting in java
Number Formatting in Java | Baeldung
August 9, 2024 - DecimalFormat is one of the most popular ways to format a decimal number in Java.
🌐
Codefinity
codefinity.com › courses › v2 › 1fb0a0db-4487-432a-a9ff-7c54c61bac87 › 3a7620ae-eabd-45f2-9f94-c8695f584a3a › 66b29cb9-41e5-442c-a2ad-6ac5797307fc
Learn Getting Started with DecimalFormat | Controlling Numeric Output with DecimalFormat
You should choose DecimalFormat when you need to control decimal places, grouping separators (like commas in thousands), optional digits, or custom patterns that go beyond what String.format() offers. This makes it especially useful in financial applications, reports, or anywhere you want numbers to appear in a specific format for users. ... 12345678910111213 package com.example; import java.text.DecimalFormat; public class Main { public static void main(String[] args) { double number = 12345.6789; DecimalFormat formatter = new DecimalFormat("#,###.00"); String formatted = formatter.format(number); System.out.println("Formatted number: " + formatted); } }
🌐
Oracle
docs.oracle.com › en › java › javase › 26 › docs › api › java.base › java › text › DecimalFormat.html
DecimalFormat (Java SE 26 & JDK 26)
March 16, 2026 - A DecimalFormat pattern contains a positive and negative subpattern, for example, "#,##0.00;(#,##0.00)". Each subpattern has a prefix, numeric part, and suffix. The negative subpattern is optional; if absent, then the positive subpattern prefixed with the minus sign '-' (U+002D HYPHEN-MINUS) ...
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › text › DecimalFormat.html
DecimalFormat (Java Platform SE 7 )
A DecimalFormat pattern contains a positive and negative subpattern, for example, "#,##0.00;(#,##0.00)". Each subpattern has a prefix, numeric part, and suffix. The negative subpattern is optional; if absent, then the positive subpattern prefixed with the localized minus sign ('-' in most locales) is used as the negative subpattern.
🌐
Oracle
docs.oracle.com › en › java › javase › 25 › docs › api › java.base › java › text › DecimalFormat.html
DecimalFormat (Java SE 25 & JDK 25)
July 21, 2026 - A DecimalFormat pattern contains a positive and negative subpattern, for example, "#,##0.00;(#,##0.00)". Each subpattern has a prefix, numeric part, and suffix. The negative subpattern is optional; if absent, then the positive subpattern prefixed with the minus sign '-' (U+002D HYPHEN-MINUS) ...
🌐
Blogger
javarevisited.blogspot.com › 2012 › 03 › how-to-format-decimal-number-in-java.html
How to format Decimal Number in Java? DecimalFormat Example
April 12, 2025 - While creating an instance of DecimalFormat you can pass a String pattern that describes on which format decimal number should be formatted and then DecimalFormat.format() method will do the rest for you. In this Java tutorial we will see how to format a decimal number in 2 decimal places, format up to 3 decimal places, using a comma to separated 3 digits, etc.
🌐
University of Arizona
www2.cs.arizona.edu › classes › cs210 › fall17 › lectures › decimal_format.pdf pdf
Java API: java.text.DecimalFormat
Java API: java.text.DecimalFormat · • The DecimalFormat class provides a way to control the appearance of numbers · that are stored as String’s. • You create an instance of DecimalFormat for each format you want to use. • Note: Have to import the DecimalFormat class from the java.text ...
🌐
Java2Blog
java2blog.com › home › number › java decimalformat example
Java DecimalFormat example - Java2Blog
January 11, 2021 - DecimalFormat’s format method can be used to format a number.Once we create object of DecimalFormat object, we can call format method and pass the number as parameter.
🌐
LabEx
labex.io › tutorials › java-how-to-format-decimal-places-in-java-435617
How to format decimal places in Java | LabEx
import java.text.DecimalFormat; public class ScientificMeasurement { public static void main(String[] args) { // Formats for different scientific precision levels DecimalFormat[] formats = { new DecimalFormat("#.###"), // 3 decimal places new DecimalFormat("#.#####"), // 5 decimal places new DecimalFormat("0.00E0") // Scientific notation }; double measurement = 123.456789; for (DecimalFormat format : formats) { System.out.println(format.format(measurement)); } } }
🌐
IIT Kanpur
iitk.ac.in › esc101 › 05Aug › tutorial › java › data › decimalFormat.html
Formatting Numbers with Custom Formats
Trail: Learning the Java Language Lesson: Object Basics and Simple Data Objects · You can use the DecimalFormat class to format decimal numbers into strings. This class allows you to control the display of leading and trailing zeros, prefixes and suffixes, grouping (thousands) separators, ...
🌐
TutorialsPoint
tutorialspoint.com › java_i18n › java_i18n_decimalformat.htm
Java Internationalization - DecimalFormat Class
import java.text.DecimalFormat; public class I18NTester { public static void main(String[] args) { String pattern = "####,####.##"; double number = 123456789.123; DecimalFormat numberFormat = new DecimalFormat(pattern); System.out.println(number); System.out.println(numberFormat.format(number)); } }
🌐
JavaBeat
javabeat.net › use-decimalformat-class-in-java
How to Use DecimalFormat Class in Java
The “java.text.DecimalFormat” class in Java is used to format a number using a specified formatting pattern. These patterns can be “#”, “.”, “,”, “;” etc and can be applied to multiple data type values in a custom way.