使用 DecimalFormat 时如何防止减号?
问题描述:
我正在使用一个库,让我可以配置使用 DecimalFormat 模式格式化数字的方式.我需要删除减号以显示数字的绝对值.我试过 "0.00###;0.00###" 和 "0.00###;#" 都没有成功.我可以选择任何减号(例如0.00###;(0.00###)")但我不能没有任何符号?
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?
预先感谢您的建议,
汤姆
答
如果使用0.00###; 0.00###"(注意分号后面的空格),负号不会显示.
If you use "0.00###; 0.00###" (notice the space after the semicolon) the negative sign will not be displayed.