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!
精彩评论