Java Parse Double parseDouble(String str)

Here you can find the source of parseDouble(String str)

Description

parse Double

License

Open Source License

Declaration

public static double parseDouble(String str) throws NumberFormatException 

Method Source Code


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

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

public class Main {
    public static double parseDouble(String str, Locale locale) throws NumberFormatException {
        double val;
        try {/*from ww w  . ja  va 2s.  c  om*/
            val = Double.parseDouble(str);
        } catch (NumberFormatException ex) {
            try {
                NumberFormat numberFormat = NumberFormat.getInstance(locale);
                val = numberFormat.parse(str).doubleValue();
            } catch (ParseException e) {
                throw new NumberFormatException(e.getMessage());
            }
        }
        return val;
    }

    public static double parseDouble(String str) throws NumberFormatException {
        return parseDouble(str, Locale.getDefault());
    }
}

Related

  1. parseDouble(Object input)
  2. parseDouble(String d)
  3. parseDouble(String inStr)
  4. parseDouble(String s, Locale locale)
  5. parseDouble(String str)
  6. parseDouble(String stringValue)
  7. parseDouble(String value)
  8. ParseDoubleEx(String s, double value_if_fault)
  9. parseDoubleInCurrentDefaultLocale(String text)