Here you can find the source of parseDouble(String s, Locale locale)
Parameter | Description |
---|---|
s | the string to parse. |
locale | the locale to use for numeric conversion. |
public static double parseDouble(String s, Locale locale)
//package com.java2s; /* /*from www. j ava2 s. c om*/ * (C) Copyright 2015-2016 by MSDK Development Team * * This software is dual-licensed under either * * (a) the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation * * or (per the licensee's choosing) * * (b) the terms of the Eclipse Public License v1.0 as published by * the Eclipse Foundation. */ import java.text.NumberFormat; import java.text.ParseException; import java.util.Locale; public class Main { /** * Parse a numeric string using the specified locale. When a ParseException * is caught, the method returns Double.NaN. * * @param s * the string to parse. * @param locale * the locale to use for numeric conversion. * @return the double value. May be NaN if s is null, empty, or unparseable */ public static double parseDouble(String s, Locale locale) { if (s == null || s.isEmpty()) { return Double.NaN; } try { return NumberFormat.getNumberInstance(locale).parse(s).doubleValue(); } catch (ParseException ex) { try { return NumberFormat.getNumberInstance(Locale.US).parse(s).doubleValue(); } catch (ParseException ex1) { return Double.NaN; } } } }