Java tutorial
//package com.java2s; public class Main { public static boolean isNumeric(Object num) { if ((num == null) || (num.toString().length() <= 0)) { return false; } String str = num.toString(); if (str.length() <= 0) { return false; } if (str.matches("\\d{1,}")) { return true; } if (str.matches("^((-\\d+)|(0+))$")) { return true; } return (str.matches("^[0-9]+(.[0-9]{1,3})?$")); } }