纯css打造立体时钟
  • 12
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
By_jie

Java验证是否为纯数字

Java验证是否为纯数字

 
package rbq.codedemo;

import java.util.regex.Pattern;

/**
* Created by rbq on 2016/12/13.
*/

public class NumUtils {

public static boolean isNum(String str){

Pattern pattern = Pattern.compile("^-?[0-9]+");
if(pattern.matcher(str).matches()){
//数字
return true;
} else {
//非数字
return false;
}
}

public static boolean isNum1(String str){
//带小数的
Pattern pattern = Pattern.compile("^[-+]?[0-9]+(\\.[0-9]+)?$");

if(pattern.matcher(str).matches()){
//数字
return true;
} else {
//非数字
return false;
}
}

}
posted @ 2018-12-22 21:15  1024军团  阅读(3216)  评论(0)    收藏  举报