Java Double Number Parse toDouble(Locale locale, String value)

Here you can find the source of toDouble(Locale locale, String value)

Description

to Double

License

Open Source License

Declaration

public static double toDouble(Locale locale, String value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.NumberFormat;
import java.text.ParsePosition;
import java.util.Locale;

public class Main {
    public static double toDouble(Locale locale, String value) {
        value = value.trim();//from   ww w . j a v  a 2s.  c  om
        ParsePosition pos = new ParsePosition(0);
        Number result = NumberFormat.getInstance(locale).parse(value, pos);
        if (pos.getIndex() != value.length())
            throw new NumberFormatException("Could not parse: " + value);
        return result.doubleValue();
    }
}

Related

  1. toDouble(final Object o, final String pattern)
  2. tryParseDoubleValue(String s, double[] result)