我正在使用 GWT 创建一个用户界面,并且有很多双值框,但是当我设置一些包含超过 3 位小数的变量时,我的 DoubleBox 不接受并截断仅保留 3 位的数字。
正常吗?
最好的解决方案是什么?
谢谢你。
As the javadoc says DoubleBox
is a ValueBox
using a DoubleParser
and DoubleRenderer
. Those rely on NumberFormat.getDecimalFormat()
which will trunk at 3 decimals in most (if not all) locales (for the default locale: http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/i18n/client/constants/NumberConstantsImpl.properties)
If you want another format, then use a ValueBox
with a NumberFormatRenderer
with your custom NumberFormat
pattern (and either use the DoubleParser
or make your own Parser
with your custom NumberFormat
pattern)