数据类型 java转换

来源:互联网 发布:mac 系统占用空间过大 编辑:程序博客网 时间:2024/06/07 16:15
1.     String转Long
            

 Long reportRecordId = NumberUtil.convert(String reportRecord, Long.class);

2.    HashMap 转成 实体entity

      BeanUtils.populate(p, map); 

  1.  public void test1() throws Exception {  
  2.         Map map = new HashMap();  
  3.         map.put("name""xiazdong");  
  4.         map.put("age""20");  
  5.         Person p = new Person();  
  6.         BeanUtils.populate(p, map);  
  7.         System.out.println(p.getAge());  
  8.     } 

  1. String[] values = new String[]{};  
  2. (long[])ConvertUtils.convert(values, long.class)
3.  需要转成Date类型的数据都要通过DateLocaleConverter这个转换器的处理
ConvertUtils.register(new DateLocaleConverter(), Date.class);



0 0
原创粉丝点击