如何在java中获取当前日期详细信息?我开发了一个类:
public class RetailerWs {
public String customerData(){
String customerInfo = "";
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/pro","root","");
//Find customer information where the customer ID is maximum
PreparedStatement statement = con.prepareStatement("select * from orders where status='Q' AND date='2012-08-01'");
ResultSet result = statement.executeQuery();
int count=0;
count++;
// System.out.println(count);
while(result.next()){
System.out.println(count);
}
}
catch(Exception exc){
System.out.println(exc.getMessage());
}
return customerInfo;
}
}
这是另一堂课。
public class Demo {
public static void main(String[] args){
RetailerWs obj = new RetailerWs();
System.out.println(obj.customerData());
}
}
如果我运行demo
,它会在之后调用RetailerWs
它显示的值count
。问题是目前我手动插入日期,即
PreparedStatement statement = con.prepareStatement("select * from orders where status='Q' AND date='2012-08-01'");
但我想要一个获取当前日期的查询。如何创建和调用它?请帮我。