GWT - DoubleBox with more than 3 decimal places

前端 未结 1 836
终归单人心
终归单人心 2021-01-19 05:56

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

相关标签:
1条回答
  • 2021-01-19 06:47

    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)

    0 讨论(0)
提交回复
热议问题