code_junkie

GWT get users local decimal separator char

Nov 13th, 2011
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. NumberFormat.getDecimalFormat()...
  2.  
  3. import com.google.gwt.i18n.client.NumberFormat;
  4.  
  5. NumberFormat fmt = NumberFormat.getDecimalFormat();
  6. double value = 1234.5;
  7. String formatted = fmt.format(value);
  8. String thousandSeparator = formatted.substring(1,2);
  9. String decimalSeparator = formatted.substring(5,6);
  10.  
  11. import com.google.gwt.i18n.client.LocaleInfo;
  12.  
  13. String decimalSeparator = LocaleInfo.getCurrentLocale().getNumberConstants().decimalSeparator();
  14. String thousandSeparator = LocaleInfo.getCurrentLocale().getNumberConstants().groupingSeparator();
Add Comment
Please, Sign In to add comment