使用 DecimalFormat 时如何防止减号? [英] How to prevent minus sign when using DecimalFormat?

查看:68
本文介绍了使用 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.

这篇关于使用 DecimalFormat 时如何防止减号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆