I'm trying to get a pop up as soon as a user logs in. I already have the pop up, but it keeps popping up all the results one at a time when I only need it to pop up within 15 minutes before the appointment time. How can I focus it to just do that?
Here is my code:
public Reminder() {
String query = "SELECT contact, start FROM appointment WHERE createdBy = '" + MainApp.currentUser + "'";
try {
ps = connection.prepareStatement(query);
rs = ps.executeQuery();
while(rs.next()) {
Timestamp tsStart = rs.getTimestamp("start");
ZoneId newZid = ZoneId.systemDefault();
ZonedDateTime newZdtStart = tsStart.toLocalDateTime().atZone(ZoneId.of("UTC"));
ZonedDateTime newLocalStart = newZdtStart.withZoneSameInstant(newZid);
// System.out.println(newLocalStart);
// ChronoLocalDateTime<?> cldt = null;
// if (rs.getTimestamp("start").toLocalDateTime().plusMinutes(15).isAfter(LocalDateTime.now())) {
// if (rs.getTimestamp("start").toLocalDateTime().plusMinutes(15).isBefore(LocalDateTime.now())) {
if(LocalDateTime.now().plusMinutes(15).isBefore(rs.getTimestamp("start").toLocalDateTime())) {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.initOwner(dialogStage);
alert.setTitle("Appointment Schedule");
alert.setHeaderText("You have an appointment!");
alert.setContentText("Starts at " + newLocalStart + " with " + rs.getString("contact"));
alert.showAndWait();
}
}
ps.execute();
ps.close();
} catch (SQLException e) {
e.printStackTrace();
}
}