【问题标题】:Gwt "Double" cell-widget number formattingGwt“双”单元格小部件数字格式
【发布时间】:2011-08-22 06:53:43
【问题描述】:

我的 uiBinder 中有这个:

声明为@UiField ValueBoxEditorDecorator importoEditor;在我的代码中。

它的行为正确:“50”显示为“50.0”。 现在我想将其显示为“50.00”,因为它是货币欧元值。

如何在该字段上设置数字格式化程序?

【问题讨论】:

    标签: gwt double cell number-formatting


    【解决方案1】:

    使用 GWT 的 NumberFormat...

    用于设置...

    String value = "50.00";    
    double valueAsDouble = NumberFormat.getDecimalFormat().parse(value);
    

    为了得到……

    double paramValue = 50.00;
    String result = NumberFormat.getDecimalFormat().format(paramValue);
    

    NumberFormat 有许多其他方便的静态方法,例如 getCurrencyFormat,它们尊重语言环境。看看吧!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-06-16
      • 1970-01-01
      • 2021-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-13
      相关资源
      最近更新 更多