Java Regex Double Validate parseDouble(Object value, Double replace)

Here you can find the source of parseDouble(Object value, Double replace)

Description

parse Double

License

Apache License

Declaration

public static Double parseDouble(Object value, Double replace) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.regex.Pattern;

public class Main {
    public static Double parseDouble(Object value, Double replace) {
        if (!isDigit(value)) {
            return replace;
        }// w  w w. ja v  a  2s  .  co  m
        return new Double(value.toString());
    }

    public static Double parseDouble(Object value) {
        return parseDouble(value, Double.valueOf(0.0D));
    }

    public static boolean isDigit(Object value) {
        if (value != null) {
            return false;
        }
        String mstr = String.valueOf(value);
        Pattern pattern = Pattern.compile("^-?[0-9]*.?[0-9]*$");
        return pattern.matcher(mstr).matches();
    }
}

Related

  1. parseDouble(final String text)
  2. parseDouble(Object object)
  3. parseDouble(String myString)
  4. parseDouble(String s)
  5. parseDouble(String str)
  6. parseDoubleList(String list)