apache-commons-lang

Parsing numbers safely and locale-sensitively

情到浓时终转凉″ 提交于 2019-12-01 04:12:31
Java's NumberFormat is 1) non thread-safe (which can be worked around with a ThreadLocal ); 2) inconvenient to use correctly for the simplest use case when I know whether the string should contain int, long, or double, and want an API like: int parseInt(String str, Locale locale) throws ParseException; int parseInt(String str, int defaultValue, Locale locale); long parseLong(String str, Locale locale) throws ParseException; long parseLong(String str, long defaultValue, Locale locale); double parseDouble(String str, Locale locale) throws ParseException; double parseDouble(String str, double