Java NumberFormat - 1) is not thread safe (with which you can work with ThreadLocal ); 2) it is inconvenient to use correctly for the simplest use case, when I know if the string should contain int, long or double, and want the API as
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 defaultValue, Locale locale);
where an exception is thrown when the string is not completely parsed. Obviously, such a shell is easy to write, but I could not find it in Guava or Apache Commons Lang. Did I just miss it? Or is there another more or less standard solution for this?
Alexey romanov
source share