| | |
| | | Matcher matcher = pattern.matcher(str); |
| | | return matcher.matches(); |
| | | } |
| | | public static boolean isNumber(String str) { |
| | | //采用正则表达式的方式来判断一个字符串是否为数字,这种方式判断面比较全 |
| | | //可以判断正负、整数小数 |
| | | |
| | | boolean isInt = Pattern.compile("^-?[1-9]\\d*$").matcher(str).find(); |
| | | boolean isDouble = Pattern.compile("^-?([1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*|0?\\.0+|0)$").matcher(str).find(); |
| | | |
| | | return isInt || isDouble; |
| | | |
| | | } |
| | | public static long dateToLongSec(String utc) { |
| | | // MyLog.i("dateToLongSec:"+utc); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); |