Reputation: 14286
How can I get users local decimal separator character from GWT. I have found the NumberFormat utility, which only returns the whole format and provides parsing.
NumberFormat.getDecimalFormat()...
Is there a (simple) way to get the decimal separator, thousand separator from the decimal format.
Upvotes: 3
Views: 2992
Reputation: 304
import com.google.gwt.i18n.client.LocaleInfo;
String decimalSeparator = LocaleInfo.getCurrentLocale().getNumberConstants().decimalSeparator();
String thousandSeparator = LocaleInfo.getCurrentLocale().getNumberConstants().groupingSeparator();
Upvotes: 14
Reputation: 34802
You can seed it with a known number and then parse it for the characters you want.
import com.google.gwt.i18n.client.NumberFormat;
NumberFormat fmt = NumberFormat.getDecimalFormat();
double value = 1234.5;
String formatted = fmt.format(value);
String thousandSeparator = formatted.substring(1,2);
String decimalSeparator = formatted.substring(5,6);
Upvotes: 2