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
。如何解决?感谢你