Как преобразовать TimeStamp в дату в Java?

Как мне преобразовать «timeStamp» в dateпосле того, как я получу счет в java?

Мой текущий код выглядит следующим образом:

public class GetCurrentDateTime {

    public int data() {
        int count = 0;
        java.sql.Timestamp timeStamp = new Timestamp(System.currentTimeMillis());
        java.sql.Date date = new java.sql.Date(timeStamp.getTime()); 
        System.out.println(date);
        //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;
    }
}

Это моя база данных: enter image description here

Здесь я получил результат 2012 -08 -07 0, но эквивалентный запрос возвращает 3. Почему я получаю 0?

98
задан Dennis Meng 8 October 2014 в 04:43
поделиться