ps.setTimestamp(1,new Timestamp(cc.getTime().getTime()));

解决方案 »

  1.   

    再请教一个问题 , 下面两个方法有什么区别, 谢谢! void setTimestamp(int parameterIndex, Timestamp x)  void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) 
               
      

  2.   

    setTimestamp(int parameterIndex, Timestamp x, Calendar cal) Sets the designated parameter to the given java.sql.Timestamp value, using the given Calendar object. The driver uses the Calendar object to construct an SQL TIMESTAMP value, which the driver then sends to the database. With a a Calendar object, the driver can calculate the timestamp taking into account a custom timezone. If no Calendar object is specified, the driver uses the default timezone, which is that of the virtual machine running the application.
      

  3.   

    可以直接用字符串插入日期时间,to_date('1980-4-5 10:35:56', 'yyyy-mm-dd hh24:mi:ss')就可以了,时间也很容易直接转换成字符串:
    SimpleDateFormat simDate =  new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");
    java.util.Date collectTime = new java.util.Date();
    String strCollectTime = simDate.format(collectTime );