| package com.zy.common.utils; | 
|   | 
| import java.math.BigDecimal; | 
|   | 
| /** | 
|  * Created by vincent on 2020-06-03 | 
|  */ | 
| public class CommonUtils { | 
|   | 
|     public static Integer parseInt(Object value){ | 
|         if(null == value){ | 
|             return null; | 
|         } | 
|         String name = value.getClass().getSimpleName().toLowerCase(); | 
|         if(name.equals("float")){ | 
|             return ((Float)value).intValue(); | 
|         } else if(name.equals("double")){ | 
|             return ((Double)value).intValue(); | 
|         } else if(name.equals("bigdecimal")) { | 
|             return ((BigDecimal)value).intValue(); | 
|         } else if(name.equals("long")) { | 
|             return ((Long)value).intValue(); | 
|         } else if(name.contains("int")) { | 
|             return (Integer)value; | 
|         } else { | 
|             return Double.valueOf(""+value).intValue(); | 
|         } | 
|     } | 
|   | 
|     public static boolean isNumeric(String str) { | 
|         // 如果字符串为空,直接返回false | 
|         if (str == null || str.length() == 0) { | 
|             return false; | 
|         } | 
|         // 用正则表达式匹配数字 | 
|         return str.matches("-?\\d+(\\.\\d+)?"); | 
|     } | 
|   | 
|     public static boolean isBoolean(String str) { | 
|         if (str == null) { | 
|             return false; | 
|         } | 
|   | 
|         if (str.length() == 4 || str.length() == 5) { | 
|             if (str.equals("true") || str.equals("false")) { | 
|                 return true; | 
|             } | 
|         } | 
|   | 
|         return false; | 
|     } | 
|   | 
|   | 
| } |