Display Negative Number in Parentheses in Java

In this post, we will see how to display negative number in Parentheses in Java.

We can use pattern #,##0.00;(#,##0.00) with DecimalFormat‘s format() to display negative number in Parenthesis in Java.

Output

If you don’t need decimal places, you can change to pattern to:

Let’s understand meaning of pattern #,##0.00;(#,##0.00):

  • First part of up to semicolon is used to format positive numbers
  • Second part after semicolon is used to format negative numbers with parenthesis.

That’s all about how to display negative number in Parentheses in Java.

Was this post helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *