【发布时间】:2012-08-06 10:43:37
【问题描述】:
这是我的数据库:
date status
1343469690 Q
1343470540 C
1343470556 P
我已经写了这段代码:
public class TodayQ {
public int data() {
int count = 0;
//count++;
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/pro", "root", "");
PreparedStatement statement = con.
prepareStatement("select * from orders where status='Q' AND date=CURDATE()");
ResultSet result = statement.executeQuery();
while (result.next()) {
// Do something with the row returned.
count++; //if the first col is a count.
}
} catch (Exception exc) {
System.out.println(exc.getMessage());
}
return count;
}
}
当日期为yyyy-mm-dd 格式时,它可以成功运行。但现在我的日期是1343469690 格式的时间戳。如何获取计数值?
【问题讨论】:
-
“获取”日期的代码在哪里?您是否看到任何错误/异常?
-
究竟是什么问题? 以什么方式不起作用?
-
当日期为 yyyy-mm-dd 格式时,t 可以成功运行。但现在我的日期是 1343469690 格式的时间戳。如何获取dis时间戳格式的计数值?