title: Adding hours, minutes and seconds to java SQL Date
body: <p>I'm having some trouble counting values from my data base with Java.</p>
  
  <p>I'm trying to count some values by date from my DB, but they have hours, minutes and seconds. If I search with <code>java.sql.Date</code>'s it just allows me to enter year, month and day, so the values with a date: <code>year"-"month"-31 (hour:minutes:seconds != 00:00:00)"</code> won't be counted.</p>
  
  <p>Is there a way to add hours, minutes, and seconds to a <code>java.sql.Date</code>? If not, what would it be a better way to do it?</p>
  
  <p>My code:</p>
  
  <pre><code>public static int getAmountPos(Connection con, Integer month, Integer year) {
  
          java.sql.Date date1 = java.sql.Date.valueOf(year+"-"+month+"-01");
          java.sql.Date date2 = java.sql.Date.valueOf(year+"-"+month+"-31");
  
          Integer amount = null;
          String sql = "SELECT COUNT(*) AS 'cantidad' "
                  + " FROM table.point_of_service "
                  + " WHERE registration_date between ? AND ?";
  
          PreparedStatement ps = con.getPreparedStatement(sql);
          ps.setDate(1, date1);
          ps.setDate(2, date2);
  
          ResultSet rs = ps.executeQuery();
  
          if(rs.next()) {
              amount = rs.getInt("cantidad");
          }
  
          return amount;
      }
  </code></pre>