我正在寻找一种方法来获取今天的日期并传递给 sql 表并保存在那里。调用保存的日期并使用 JODA TIME API 执行一些任务。更改后的 Joda 时间日期到 sql 表并保存在那里并继续处理..
我试过这个方法
//prints todays date
java.sql.Date sqlDate = new java.sql.Date(new Date().getTime());
//passes wrong date to the table like 1970-07-01 instead of 2013-03-01
String insert = "INSERT INTO TEST_TABLE VALUES(1,"+sqlDate+")";
pStmt = conn.prepareStatement(insert);
pStmt.executeUpdate();
//converting to joda time
LocalDate ld = new LocalDate(sqlDate);
//some calculations, and how to convert back to sql date?
我在这里要做的是,一个包含 3 列(id、startdate、finishdate)的表。id 将由用户输入,开始日期应自动输入今天的日期。在使用 joda 时间和完成日期进行一些计算后,将设置为完成日期。
代码
String insert = "INSERT INTO TEST_TABLE VALUES(2,'"+timestamp+"')";
错误
Data type mismatch in criteria expression
//I have created table using MS access
//the format of the date column is Date/Time.