GWT - DoubleBox with more than 3 decimal places

帅比萌擦擦* 提交于 2019-12-20 01:36:44

问题


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.


回答1:


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)



来源:https://stackoverflow.com/questions/12245622/gwt-doublebox-with-more-than-3-decimal-places

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!