问题描述
我正在使用GWT创建一个用户界面,并且有许多双重值,但是当我设置一些包含超过3个小数位的变量时,我的DoubleBox不接受并截断只有3个位置的数字。是否正常?
最好的解决方案是什么?
谢谢。
由于javadoc说 DoubleBox
一个 ValueBox
使用 DoubleParser
和 DoubleRenderer
。那些依赖于 NumberFormat.getDecimalFormat()
,它将在大多数(如果不是全部)区域设置中以3位小数中继(对于默认语言环境:)
如果您想要另一种格式,请使用 ValueBox
与 NumberFormatRenderer
与您的自定义 NumberFormat
pattern(并使用 DoubleParser
或自己创建 Parser
与您的自定义 NumberFormat
模式)
I'm creating an user interface using GWT and there're many boxes of double values but when I set some variable which contains more than 3 decimal places my DoubleBox doesn't accept and truncates the number letting just 3 places.
Is it normal?
What's the best solution?
Thank you.
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)
这篇关于GWT - 具有3位小数位数的DoubleBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!