首页 > 代码库 > 把字符串转换为Double 类型

把字符串转换为Double 类型

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

 

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

把字符串转换为Double 类型