Timestamp 类型转换 时间后面多了.0转换报错

 

	Timestamp ts =null;  
		String tsTime = "2016-05-09 11:49:45.0";  
        try {  
            ts = Timestamp.valueOf(tsTime ); 
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");  
            System.out.println(sdf.format(ts));    
        } catch (Exception e) {  
            e.printStackTrace();  
        }  


如果转date就更简单了:
String tsStr = "2011-05-09 11:49:45.0";  
Date  ts1 = Timestamp.valueOf(tsStr);




你可能感兴趣的:(Timestamp 类型转换 时间后面多了.0转换报错)