Search code examples
javasignnumber-formatting

How to prevent minus sign when using DecimalFormat?


I am using a library that lets me configure the way numbers are formatted using a DecimalFormat pattern. I need to remove the minus symbol to show the absolute value of the numbers. I have tried both "0.00###;0.00###" and "0.00###;#" without success. I can choose any minus symbol (e.g. "0.00###;(0.00###)") but I can't have no sign at all?

Thanks in advance for your suggestions,

Tom


Solution

  • If you use "0.00###; 0.00###" (notice the space after the semicolon) the negative sign will not be displayed.