Java I18n 简明教程
Java Internationalization - Parse Numbers
Example
在此示例中,我们展示了在不同语言环境中出现的数字的解析。
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"));
}
}