把字符串转换为Double 类型

//把字符串转换为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;
        }

时间: 2024-08-02 18:36:28

把字符串转换为Double 类型的相关文章

字符串转换为数字类型

// @param s为字符串,n为数字function fn(obj){    //转换为String类型    var s = obj +"";    //转换为number类型    var n = +obj;}

C语言atof()函数:将字符串转换为double(双精度浮点数)

头文件:#include <stdlib.h> 函数 atof() 用于将字符串转换为双精度浮点数(double),其原型为:double atof (const char* str); atof() 的名字来源于 ascii to floating point numbers 的缩写,它会扫描参数str字符串,跳过前面的空白字符(例如空格,tab缩进等,可以通过 isspace() 函数来检测),直到遇上数字或正负符号才开始做转换,而再遇到非数字或字符串结束时('\0')才结束转换,并将结果

不使用java内置函数,将String字符串转换为int类型

package com.test; public class AtoiTest { public static void main(String[] args) throws Exception { String s = "-011134"; System.out.println("转换前的字符串:" + s); System.out.println("atoi1转换后的字符串:" + atoi1(s)); System.out.println(

如何实现@ResponseBody,把Json字符串转换为指定类型

1.问题 spring 是如何把 http中的body,转换为指定类的,里面的难点其实在于泛型的处理. 2.Spring的处理 2.1 HandlerMethod 这个类Spring对Method的封装,例如使用@RequestMapping注解方法,会使用HandlerMethod封装(其实是其子类InvocableHandlerMethod).然后由InvocableHandlerMethod对其进行调用 HandlerMethod的属性如下 private final Object bea

将yyyyMMdd,dd/MM/yyyy 类型字符串转换为datetime 类型 yyyy-MM-dd C#

DateTime ConvertDate = DateTime.ParseExact("20140504", "yyyyMMdd", null, System.Globalization.DateTimeStyles.AllowWhiteSpaces).ToString("yyyy-MM-dd"); DateTime.ParseExact("18/05/2014", "dd/MM/yyyy", System

金蝶KIS新建账套时 从字符串向DateTime转换时失败 从字符串转换为Datetime类型时发生语法错误

需要修改以下几点 控制面板---区域和语言选项---区域选项---自定义,修改为如下格式

c# yyyyMMdd,dd/MM/yyyy 类型字符串转换为datetime 类型

DateTime ConvertDate  = Convert.ToDateTime(DateTime.ParseExact(item.Key, "yyyyMMdd", null, System.Globalization.DateTimeStyles.AllowWhiteSpaces).ToString("yyyy-MM-dd")); DateTime.ParseExact("18/05/2014", "dd/MM/yyyy"

Gson将字符串转换为Date类型

自定义DateAdapter public class DateAdapter implements JsonDeserializer<Date> { private final DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); public Date deserialize(JsonElement arg0, Type arg1, JsonDeserializationContext arg2) throws Json

java -------- String类型转换为数字类型

将 String类型转换为数字类型的时候要注意,数据类型的范围 整型: byte的取值范围为-128~127,占用1个字节(-2的7次方到2的7次方-1) short的取值范围为-32768~32767,占用2个字节(-2的15次方到2的15次方-1) int的取值范围为(-2147483648~2147483647),占用4个字节(-2的31次方到2的31次方-1) long的取值范围为(-9223372036854774808~9223372036854774807),占用8个字节(-2的6