Here you can find the source of fmtNumStringToDouble(String s)
public static double fmtNumStringToDouble(String s)
//package com.java2s; import java.text.DecimalFormat; import java.text.ParseException; public class Main { public static double fmtNumStringToDouble(String s) { double d = 0.0; if (s == null || s.trim().length() == 0) return 0.0; DecimalFormat DF_4_DP = new DecimalFormat("###,##0.0000"); DecimalFormat DF_2_DP = new DecimalFormat("###,##0.00"); //first try parsing as currency DecimalFormat df = DF_2_DP; try {//ww w . j a v a 2 s .c o m d = df.parse(s).doubleValue(); return d; } //if that doesn't work, try the decimal formatter catch (ParseException pe) { } df = DF_4_DP; try { d = df.parse(s).doubleValue(); } //throw an exception catch (ParseException pe) { d = 0.0; } return d; } }