Date currentDateTime;
java.sql.Date sql_currentDateTime;
currentDateTime = getCurrentDateTime(); //Fri Jun 21 15:53:59 AZST 2013
sql_currentDateTime = new java.sql.Date(currentDateTime.getTime()); //2013-06-21
PreparedStatement insertStmt = null;
sqlToMessage = "insert into message values (?)";
insertStmt = conn.prepareStatement(sqlToMessage);
insertStmt.setDate(1, sql_currentDateTime);
insertStmt.executeUpdate();
我想将当前日期时间(20-Jun-13 16:04:32)插入数据库。但数据插入到数据库20-Jun-13
,而不是像20-Jun-13 16:04:32
。怎么解决?谢谢你
答案 0 :(得分:1)
答案 1 :(得分:0)
将数据库列从日期更改为时间戳