使用以下的语句
pstmt.setDate("UpdateDate", rs.getDate("UpdateDate"));
为什么插入数据库的是yyyy-MM-dd
而不是yyyy-MM-dd HH:mm:ss
我想插入的是yyyy-MM-dd HH:mm:ss这种格式的该怎么做了

解决方案 »

  1.   

    先把java.sql.Date转化为java.util.Date
      

  2.   

    看看我写的一个方法,是将现在的时间转化为yy-MM-dd HH:mm:ss的,仅供参考:
        /**
         * 取出现在的时间,年-月-日 小时-分-秒
         * @param currentTime long
         * @return String
         */
        public String getCurrentDate(long currentTime){
         DateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         String time = df.format(new Date(currentTime));
    return time;
        }
      

  3.   

    pstmt.setTimestamp("UpdateDate", rs.getTimestamp("UpdateDate"));