Java - Write code to check if a string is Double using regex

Requirements

Write code to check if a string is Double using regex

Demo

import java.util.regex.Pattern;

public class Main {
  public static void main(String[] argv) {
    String str = "123123.123";
    System.out.println(isDouble(str));
  }//from  w w w .  j  a  v a 2  s  .  c  om

  public static boolean isDouble(String str) {
    if (isNotNull(str)) {
      Pattern pattern = Pattern.compile("^[-\\+]?[.\\d]*$");
      return pattern.matcher(str).matches();
    }
    return false;
  }

  public static boolean isNotNull(String str) {
    if (null != str && !"".equals(str)) {
      return true;
    } else {
      return false;
    }
  }

  public static boolean isNotNull(StringBuilder str) {
    if (null != str && !"".equals(str.toString())) {
      return true;
    } else {
      return false;
    }
  }

}

Related Exercise