开发者

Gwt "Double" cell-widget number formatting

I have this in my uiBinder:

开发者_开发百科

Declared as @UiField ValueBoxEditorDecorator importoEditor; in my code.

It behaves correctly: "50" displays as "50.0". Now I want to display it as "50.00", since it is a currency euro value.

How can I set a number formatter on that field?


Use GWT's NumberFormat...

For setting...

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

For getting...

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

NumberFormat has lots of other convenient static methods, like getCurrencyFormat, that respect locale. Check it out!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜