| | |
| | | import java.text.DecimalFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.GregorianCalendar; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | |
| | | import net.sourceforge.pinyin4j.PinyinHelper; |
| | | import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; |
| | | import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; |
| | | import org.springframework.cglib.beans.BeanMap; |
| | | |
| | | public class SimpleTool { |
| | | |
| | | public static SimpleDateFormat myformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | public static DecimalFormat fmt = new DecimalFormat("0.00"); |
| | | public static Byte[] lock = new Byte[] {0}; |
| | | |
| | | |
| | | /**对象转map*/ |
| | | public static Map<?, ?> objectToMap(Object obj) { |
| | | if(obj == null) |
| | | return null; |
| | | |
| | | return new org.apache.commons.beanutils.BeanMap(obj); |
| | | } |
| | | |
| | | /** |
| | | * 将对象装换为map |
| | | * |
| | | * @param bean |
| | | * @return |
| | | */ |
| | | public static <T> Map<String, Object> beanToMap(T bean) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if (bean != null) { |
| | | BeanMap beanMap = BeanMap.create(bean); |
| | | for (Object key : beanMap.keySet()) { |
| | | map.put(key + "", beanMap.get(key)); |
| | | } |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 将对象装换为map |
| | | * |
| | | * @param bean |
| | | * @return |
| | | */ |
| | | public static Map<String, String> beanToMapS(Object bean) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | if (bean != null) { |
| | | BeanMap beanMap = BeanMap.create(bean); |
| | | for (Object key : beanMap.keySet()) { |
| | | if(beanMap.get(key) != null){ |
| | | map.put(key + "", beanMap.get(key).toString()); |
| | | }else{ |
| | | map.put(key + "", ""); |
| | | } |
| | | } |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 后台格式构建返回值格式列表-后台获取列表 |
| | | * @param count 返回总条数 |