Ok, so currently I have a database that has the following time frame:
id 1 startTime 2013-09-09 15: 05: 10.0 endTime 2013-09-09 15: 05: 10.0
id 2 startTime 2013-09-09 15: 09: 54.0 endTime 2013-09-09 15: 09: 54.0
id 3 startTime 2013-09-09 15: 20: 46.0 endTime 2013-09-09 15: 20: 46.0
id 4 startTime 2013-09-09 15: 21: 06.0 endTime 2013-09-09 15: 21: 06.0
id 5 startTime 2013-09-09 15: 21: 34.0 endTime 2013-09-09 15: 21: 34.0
id 6 startTime 2013-09-09 15: 22: 34.0 endTime 2013-09-09 15: 22: 34.0
id 7 startTime 2013-09-09 15: 23: 06.0 endTime 2013-09-09 15: 25: 34.0
now when i run the time search method located here:
@Override
public ArrayList<AppointmentAccess> searchByTime(Timestamp startTime,
Timestamp endTime) throws SQLException {
ArrayList<AppointmentAccess> appointmentList = new ArrayList<AppointmentAccess>();
String preparedQuery = "Select DISTINCT * From Appointments where startTime <= appointments.endTime AND endTime >= appointments.startTime";
try (Connection connection = DriverManager.getConnection(url, user,
password);
PreparedStatement ps = connection.prepareStatement(preparedQuery);
ResultSet query = ps.executeQuery();) {
while (query.next()) {
AppointmentAccess appointment = new AppointmentAccess();
appointment.setStartTime(query.getTimestamp("starttime"));
appointment.setEndTime(query.getTimestamp("endtime"));
appointment.setAlarmReminder(query
.getBoolean("alarmreminder"));
appointment.setAllDay(query.getBoolean("allday"));
appointment.setDetails(query.getString("details"));
appointment.setLocation(query.getString("location"));
appointment.setTitle(query.getString("title"));
appointmentList.add(appointment);
}
}
return appointmentList;
}
"searchTooLate, searchTooEarly searchTimeBetweenAppointments" .
, :
startTime: "2013-09-09 16:05:09"
endTime: "2013-09-09 16:22:35"
startTime: "2013-09-09 15: 24: 06.0"
endTime: "2013-09-09 15: 25: 30.0"
startTime: "2013-08-09 14:05:09"
endTime: "2013-08-09 16:22:35"
?
user2855789