parse String To Double - Java java.lang

Java examples for java.lang:double Format

Description

parse String To Double

Demo Code


import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.log4j.Logger;

public class Main{
    public static void main(String[] argv) throws Exception{
        String amout = "java2s.com";
        System.out.println(parseToDouble(amout));
    }//from   w ww  . j a  v  a  2 s . com
    
    public static Double parseToDouble(String amout) {
        if (amout == null)
            return null;
        String s = amout.replaceAll(",", "");
        return Double.valueOf(s);
    }
}

Related Tutorials