开发者

how the best way to get double from String "1,000.0" in java [duplicate]

This question already has answers here: Closed 11 years ago.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜