Java-i18n-parse-numbers
提供:Dev Guides
Java内部化-数値の解析
この例では、異なるロケールに存在する数値の解析を示しています。
IOTester.java
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Locale;
public class I18NTester {
public static void main(String[] args) throws ParseException {
Locale enLocale = new Locale("en", "US");
Locale daLocale = new Locale("da", "DK");
NumberFormat numberFormat = NumberFormat.getInstance(daLocale);
System.out.println(numberFormat.parse("100,76"));
numberFormat = NumberFormat.getInstance(enLocale);
System.out.println(numberFormat.parse("100,76"));
}
}
出力
次の結果が出力されます。
100.76
10076
link:/cgi-bin/printpage.cgi [__印刷]