3

GWTからユーザーにローカル小数点記号を取得するにはどうすればよいですか。フォーマット全体を返し、解析を提供するNumberFormatユーティリティを見つけました。

NumberFormat.getDecimalFormat()...

10進形式から小数点記号、千単位の区切り文字を取得する(簡単な)方法はありますか?

4

2 に答える 2

14
import com.google.gwt.i18n.client.LocaleInfo;

String decimalSeparator = LocaleInfo.getCurrentLocale().getNumberConstants().decimalSeparator();
String thousandSeparator = LocaleInfo.getCurrentLocale().getNumberConstants().groupingSeparator();
于 2011-05-02T10:04:11.777 に答える
2

既知の数値でシードしてから、必要な文字を解析できます。

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);
于 2009-01-25T07:23:34.883 に答える