how the best way to get double from String "1,000.0" in java [duplicate]
Possible Duplicate:
Convert a String to Number - Java
String s="1,000.0";
how can I get double value from this Stri开发者_如何学Gong?
thanks for help :)
NumberFormat formatter = NumberFormat.getInstance(new Locale("en_US"));
try {
System.out.println(formatter.parse("1,000.0"));
} catch (ParseException e) {
// Handle this
}
Another option is DecimalFormat.parse(String, ParsePosition).
i think this example works:
String to Double - Java
精彩评论