ResultSet rs = stmt.executeQuery("SELECT * FROM employees"); while (rs.next()) { Date hireDate = rs.getDate("hire_date"); // do something with hireDate }
ResultSet rs = stmt.executeQuery("SELECT * FROM sales"); while (rs.next()) { Date saleDate = rs.getDate("sale_date"); if (saleDate.before(new Date())) { // do something } }This example retrieves the "sale_date" column from the ResultSet object and checks if it is before the current date, using the java.util.Date class. The ResultSet.getDate method is located in the java.sql package library, which is used for JDBC-related classes and interfaces.