开发者

Gwt "Double" cell-widget number formatting

开发者 https://www.devze.com 2023-03-30 05:48 出处:网络
I have this in my uiBinder: 开发者_开发百科 Declared as @UiField ValueBoxEditorDecorator importoEditor; in my code.

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

精彩评论

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

关注公众号