码迷,mamicode.com
首页 > 其他好文 > 详细

把字符串转换为Double 类型

时间:2014-11-06 12:22:36      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:io   ar   for   sp   on   log   bs   amp   ef   

 //把字符串转换为Double 类型
    public Double convertStringToDouble(String value){
           
           Double doubleValue = new Double("0.00");
           if(value != null && !"".equals(value))
              doubleValue = new Double(value.replaceAll(",",""));
              
           return doubleValue;
        }

 

  public Integer convertStringToInteger(String value){
           
           Integer intValue = new Integer("0");
           if(value != null && !"".equals(value))
              intValue = new Integer(value);
              
           return intValue;
        }
        
    //把字符串转换为Date类型    
    public Date convertStringToDate(String value){
        
          Date dateValue = null;
          
          if(value != null && !"".equals(value)){
            try{
            SimpleDateFormat   format = new SimpleDateFormat("yyyy-MM-dd");  
            dateValue = format.parse(value);
            }catch(Exception e){
                  log.error("convertStrngToDouble:日期转换错误!");
                  e.printStackTrace();
                }
            
            }
            
          return dateValue;
        }  
   

把字符串转换为Double 类型

标签:io   ar   for   sp   on   log   bs   amp   ef   

原文地址:http://www.cnblogs.com/curtainy/p/4078104.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!