List of usage examples for java.time LocalDate isBefore
@Override public boolean isBefore(ChronoLocalDate other)
From source file:serposcope.controllers.google.GoogleSearchController.java
public Result search(Context context, @PathParam("searchId") Integer searchId, @Param("startDate") String startDateStr, @Param("endDate") String endDateStr) { GoogleSearch search = getSearch(context, searchId); Group group = context.getAttribute("group", Group.class); if (search == null) { context.getFlashScope().error("error.invalidSearch"); return Results.redirect( router.getReverseRoute(GoogleGroupController.class, "view", "groupId", group.getId())); }// w ww . j ava 2 s. c o m Run minRun = baseDB.run.findFirst(Module.GOOGLE, STATUSES_DONE, null); Run maxRun = baseDB.run.findLast(Module.GOOGLE, STATUSES_DONE, null); if (maxRun == null || minRun == null) { return Results.ok().render("search", search); } LocalDate minDay = minRun.getDay(); LocalDate maxDay = maxRun.getDay(); LocalDate startDate = null; if (startDateStr != null) { try { startDate = LocalDate.parse(startDateStr); } catch (Exception ex) { } } LocalDate endDate = null; if (endDateStr != null) { try { endDate = LocalDate.parse(endDateStr); } catch (Exception ex) { } } if (startDate == null || endDate == null || endDate.isBefore(startDate)) { startDate = maxDay.minusDays(30); endDate = maxDay; } Run firstRun = baseDB.run.findFirst(Module.GOOGLE, STATUSES_DONE, startDate); Run lastRun = baseDB.run.findLast(Module.GOOGLE, STATUSES_DONE, endDate); if (firstRun == null || lastRun == null || firstRun.getDay().isAfter(lastRun.getDay())) { return Results.ok() .render("f_warning", msg.get("error.noDataForThisPeriod", context, Optional.absent()).or("")) .render("startDate", startDate).render("endDate", endDate).render("minDate", minDay) .render("maxDate", maxDay).render("search", search); } startDate = firstRun.getDay(); endDate = lastRun.getDay(); String jsonEvents = null; try { jsonEvents = objectMapper.writeValueAsString(baseDB.event.list(group, startDate, endDate)); } catch (JsonProcessingException ex) { jsonEvents = "[]"; } GoogleSerp lastSerp = googleDB.serp.get(lastRun.getId(), search.getId()); List<GoogleTarget> targets = getTargets(context); Map<Integer, GoogleBest> bestRankings = new HashMap<>(); for (GoogleTarget target : targets) { GoogleBest best = googleDB.rank.getBest(target.getGroupId(), target.getId(), search.getId()); if (best != null) { bestRankings.put(best.getGoogleTargetId(), best); } } String jsonRanks = getJsonRanks(group, targets, firstRun, lastRun, searchId); Config config = baseDB.config.getConfig(); return Results.ok().render("displayMode", config.getDisplayGoogleSearch()).render("events", jsonEvents) .render("targets", targets).render("chart", jsonRanks).render("search", search) .render("serp", lastSerp).render("startDate", startDate).render("endDate", endDate) .render("minDate", minDay).render("maxDate", maxDay).render("bestRankings", bestRankings); }
From source file:serposcope.controllers.admin.DebugController.java
@FilterWith(XSRFFilter.class) public Result dryRun(Context context, @Param("startDate") String start, @Param("endDate") String end) { long _start = System.currentTimeMillis(); FlashScope flash = context.getFlashScope(); LocalDate startDate = null;//w w w . j a va 2 s.c o m LocalDate endDate = null; try { startDate = LocalDate.parse(start); endDate = LocalDate.parse(end); } catch (Exception ex) { } if (startDate == null || endDate == null || startDate.isAfter(endDate)) { flash.error("error.invalidDate"); return Results.redirect(router.getReverseRoute(DebugController.class, "debug")); } Run lastRun = baseDB.run.findLast(Module.GOOGLE, null, null); if (lastRun != null && lastRun.getDay().isAfter(startDate)) { flash.error("error.invalidDate"); return Results.redirect(router.getReverseRoute(DebugController.class, "debug")); } LocalDate date = LocalDate.from(startDate); GoogleSettings ggOptions = googleDB.options.get(); int minPauseBetweenPageSec = ggOptions.getMinPauseBetweenPageSec(); int maxPauseBetweenPageSec = ggOptions.getMaxPauseBetweenPageSec(); ggOptions.setMinPauseBetweenPageSec(0); ggOptions.setMaxPauseBetweenPageSec(0); googleDB.options.update(ggOptions); try { while (date.isBefore(endDate)) { LOG.debug("dry run {}", date); if (!taskManager .startGoogleTask(new Run(Run.Mode.MANUAL, Module.GOOGLE, date.atTime(13, 37, 00)))) { LOG.error("can't startGoogleTask"); flash.error("can't startGoogleTask"); return Results.redirect(router.getReverseRoute(DebugController.class, "debug")); } taskManager.joinGoogleTask(); date = date.plusDays(1); } } catch (Exception ex) { LOG.error("an error occured", ex); flash.error("an error occured"); return Results.redirect(router.getReverseRoute(DebugController.class, "debug")); } finally { ggOptions.setMinPauseBetweenPageSec(minPauseBetweenPageSec); ggOptions.setMaxPauseBetweenPageSec(maxPauseBetweenPageSec); googleDB.options.update(ggOptions); } LOG.debug("dry run timing : {}", DurationFormatUtils.formatDurationHMS(System.currentTimeMillis() - _start)); flash.success("ok"); return Results.redirect(router.getReverseRoute(DebugController.class, "debug")); }
From source file:investiagenofx2.view.InvestiaGenOFXController.java
private void getTransactionsFromWeb() { try {// w w w .j a v a 2s . co m if (!htmlPage.getUrl().toString().contains("/TransactionReports/Select")) { if (InvestiaGenOFX.debug) { htmlPage = InvestiaGenOFX.getWebClient() .getPage(InvestiaGenOFX.debugFullPath + "-Transactions.htm"); } else { htmlPage = InvestiaGenOFX.getWebClient() .getPage(txt_investiaURL.getText() + "/TransactionReports/Select" + "?wcag=true"); waitForGeneratedTransactions(); } } @SuppressWarnings(("unchecked")) List<HtmlHeading4> h4from = (List<HtmlHeading4>) htmlPage .getByXPath("//h4[contains(text(),'Priode: de ')]"); String from = h4from.get(0).asText(); int index = from.indexOf("Priode: de "); LocalDate selFromDate = LocalDate.parse(from.substring(index + 12, index + 12 + 10)); if (dtp_lastDate.getValue().isBefore(selFromDate)) { @SuppressWarnings(("unchecked")) List<HtmlForm> forms = (List<HtmlForm>) htmlPage.getByXPath("//form"); HtmlForm form = forms.get(1); HtmlTextInput selPerFrom = form.getInputByName("selPerFrom"); selPerFrom.setValueAttribute(dtp_lastDate.getValue().toString()); HtmlAnchor generate = (HtmlAnchor) form.getByXPath("//a[contains(@class, 'btn-investia-blue')]") .get(0); if (InvestiaGenOFX.debug) { htmlPage = InvestiaGenOFX.getWebClient() .getPage(InvestiaGenOFX.debugFullPath + "-Transactions.htm"); } else { htmlPage = generate.click(); waitForGeneratedTransactions(); } } HtmlTable htmlTable = (HtmlTable) htmlPage.getElementById("tblTransactionReports"); if (htmlTable == null) { return; } for (int i = 0; i < htmlTable.getRowCount(); i++) { LocalDate transacDate = LocalDate.parse(htmlTable.getCellAt(i, 0).getTextContent(), DateTimeFormatter.ofPattern("dd MMM yyyy", Locale.CANADA_FRENCH)); if (transacDate.isBefore(dtp_lastDate.getValue())) { break; } String transacType = htmlTable.getCellAt(i, 2).getTextContent(); String[] token = transacType.split("[\\-/(]"); switch (token[0].replace(" ", "")) { case "Dividendes": transacType = "Distribution"; break; case "Achat": case "changeentrant": case "Prlvementautomatique": case "Transfertentrantdecourtier": case "Transfertexterneentrant": case "Transfertinterneentrant": transacType = "Purchase"; break; case "changesortant": case "Rachat": case "Transfertexternesortant": case "Transf.int.sort.": case "Transf.Int.sortant": case "Transfertinternesortant": transacType = "Switch Out"; break; case "Dpt": transacType = "Credit"; break; case "Retrait": case "Retenue": transacType = "Debit"; break; case "Crditenespces": case "Entred'espces": case "Fraisd'administration": case "Sortied'espces": case "Transfertd'espcesentrant": case "Transfertd'espcessortant": continue; default: try { throw new MyOwnException("Type de transaction non prise en charge: " + transacType.trim()); } catch (MyOwnException ex) { Logger.getLogger(OFXUtilites.class.getName()).log(Level.SEVERE, null, ex); continue; } } String transacAccount = accountOwnerName.split(" ")[0] + "\\" + htmlTable.getCellAt(i, 1).getTextContent(); String symbol = htmlTable.getCellAt(i, 3).getTextContent(); String unit = htmlTable.getCellAt(i, 5).getTextContent().replaceAll("[^0-9,]", "").replace(",", "."); String fitid = ""; String price = "0.00"; String amount; if ("Credit".equals(transacType) || "Debit".equals(transacType)) { amount = htmlTable.getCellAt(i, 9).getTextContent().replaceAll("[^0-9,]", "").replace(",", "."); fitid = StringUtils.stripAccents(htmlTable.getCellAt(i, 2).getTextContent()); } else { amount = htmlTable.getCellAt(i, 10).getTextContent().replaceAll("[^0-9,]", "").replace(",", "."); price = Float.toString(Float.parseFloat(amount) / Float.parseFloat(unit)); } if (PropertiesInit.getLinkAccountsTransac().indexOf(transacAccount) < 0) { linkAccountTransac(transacAccount); } int idxAccount = linkAccountToLocalAccountIndex[PropertiesInit.getLinkAccountsTransac() .indexOf(transacAccount)]; accounts.get(idxAccount) .add(new Transaction(transacDate, transacType, amount, fitid, symbol, unit, price, "")); } } catch (Exception ex) { Logger.getLogger(InvestiaGenOFXController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:serposcope.controllers.google.GoogleTargetController.java
public Result target(Context context, @PathParam("targetId") Integer targetId, @Param("startDate") String startDateStr, @Param("endDate") String endDateStr) { GoogleTarget target = getTarget(context, targetId); List<GoogleSearch> searches = context.getAttribute("searches", List.class); Group group = context.getAttribute("group", Group.class); Config config = baseDB.config.getConfig(); String display = context.getParameter("display", config.getDisplayGoogleTarget()); if (!Config.VALID_DISPLAY_GOOGLE_TARGET.contains(display) && !"export".equals(display)) { display = Config.DEFAULT_DISPLAY_GOOGLE_TARGET; }//from w w w .j a v a 2 s .com if (target == null) { context.getFlashScope().error("error.invalidTarget"); return Results.redirect( router.getReverseRoute(GoogleGroupController.class, "view", "groupId", group.getId())); } Run minRun = baseDB.run.findFirst(group.getModule(), RunDB.STATUSES_DONE, null); Run maxRun = baseDB.run.findLast(group.getModule(), RunDB.STATUSES_DONE, null); if (maxRun == null || minRun == null || searches.isEmpty()) { String fallbackDisplay = "export".equals(display) ? "table" : display; return Results.ok() .template("/serposcope/views/google/GoogleTargetController/" + fallbackDisplay + ".ftl.html") .render("startDate", "").render("endDate", "").render("display", fallbackDisplay) .render("target", target); } LocalDate minDay = minRun.getDay(); LocalDate maxDay = maxRun.getDay(); LocalDate startDate = null; if (startDateStr != null) { try { startDate = LocalDate.parse(startDateStr); } catch (Exception ex) { } } LocalDate endDate = null; if (endDateStr != null) { try { endDate = LocalDate.parse(endDateStr); } catch (Exception ex) { } } if (startDate == null || endDate == null || endDate.isBefore(startDate)) { startDate = maxDay.minusDays(30); endDate = maxDay; } Run firstRun = baseDB.run.findFirst(group.getModule(), RunDB.STATUSES_DONE, startDate); Run lastRun = baseDB.run.findLast(group.getModule(), RunDB.STATUSES_DONE, endDate); List<Run> runs = baseDB.run.listDone(firstRun.getId(), lastRun.getId()); startDate = firstRun.getDay(); endDate = lastRun.getDay(); switch (display) { case "table": case "variation": return Results.ok().template("/serposcope/views/google/GoogleTargetController/" + display + ".ftl.html") .render("target", target).render("searches", searches).render("startDate", startDate.toString()) .render("endDate", endDate.toString()).render("minDate", minDay).render("maxDate", maxDay) .render("display", display); case "chart": return renderChart(group, target, searches, runs, minDay, maxDay, startDate, endDate); case "export": return renderExport(group, target, searches, runs, minDay, maxDay, startDate, endDate); default: throw new IllegalStateException(); } }
From source file:ui.Analyze.java
private void generateUR(LocalDate ld1, LocalDate ld2) throws SQLException { org.jfree.data.category.DefaultCategoryDataset data = new org.jfree.data.category.DefaultCategoryDataset(); LocalDate awal, akhir, loop;// w ww .ja v a 2 s . c om boolean min; if (ld2.isBefore(ld1)) { awal = ld2; akhir = ld1; min = false; } else { akhir = ld2; awal = ld1; min = true; } for (loop = awal; min ? !loop.isAfter(akhir) : !loop.isBefore(akhir);) { data.addValue(getUntung(loop), "Untung", loop); data.addValue(getRugi(loop), "Rugi", loop); if (min) loop = loop.plusDays(1); else loop = loop.minusDays(1); } org.jfree.chart.ChartPanel cp = new org.jfree.chart.ChartPanel(ChartFactory.createBarChart("Untung Rugi", "Periode", "Nilai", data, PlotOrientation.VERTICAL, true, true, false)); cp.setSize(pnlUR.getSize()); if (0 < pnlUR.getComponentCount()) pnlUR.removeAll(); pnlUR.add(cp); }
From source file:ui.Analyze.java
private void generateLaba(LocalDate ld1, LocalDate ld2) throws SQLException { org.jfree.data.category.DefaultCategoryDataset data = new org.jfree.data.category.DefaultCategoryDataset(); javax.swing.table.DefaultTableModel m = (javax.swing.table.DefaultTableModel) ketTbl.getModel(); ketTbl.removeAll();/* w w w . j ava 2 s. co m*/ LocalDate awal, akhir, loop; boolean min; if (ld2.isBefore(ld1)) { awal = ld2; akhir = ld1; min = false; } else { akhir = ld2; awal = ld1; min = true; } for (loop = awal; min ? !loop.isAfter(akhir) : !loop.isBefore(akhir);) { Number u = getUntung(loop), r = getRugi(loop); data.addValue(u.longValue() - r.longValue(), "Laba", loop); m.addRow(new Object[] { loop, u.longValue() - r.longValue() }); if (min) loop = loop.plusDays(1); else loop = loop.minusDays(1); } org.jfree.chart.ChartPanel cp = new org.jfree.chart.ChartPanel(ChartFactory.createLineChart("Laba", "Tanggal", "Laba", data, PlotOrientation.VERTICAL, true, true, false)); cp.setSize(pnlLaba.getSize()); if (0 < pnlLaba.getComponentCount()) pnlLaba.removeAll(); pnlLaba.add(cp); }
From source file:org.efaps.esjp.common.uiform.Field_Base.java
/** * @param _parameter Parameter as passed from the eFaps API * @return Return containing Html Snipplet * @throws EFapsException on error/*from ww w . jav a2 s .c o m*/ */ public Return getOptionList4DateTime(final Parameter _parameter) throws EFapsException { final List<DropDownPosition> positions = new ArrayList<>(); final String dateFieldType = getProperty(_parameter, "DateFieldType", "YEAR"); switch (dateFieldType) { case "MONTH": for (final Month month : Month.values()) { final DropDownPosition pos = getDropDownPosition(_parameter, month.getValue(), month.getDisplayName(TextStyle.FULL, Context.getThreadContext().getLocale())); pos.setSelected(month.getValue() == new DateTime().getMonthOfYear()); positions.add(pos); } break; case "YEAR": default: final String fromStr = getProperty(_parameter, "From", "-10"); final String toStr = getProperty(_parameter, "To", "+10"); LocalDate start; if (StringUtils.isNumeric(fromStr)) { start = LocalDate.of(Integer.parseInt(fromStr), 1, 1); } else { start = LocalDate.now().plusYears(Integer.parseInt(fromStr)); } final LocalDate end; if (StringUtils.isNumeric(toStr)) { end = LocalDate.of(Integer.parseInt(toStr), 1, 1); } else { end = LocalDate.now().plusYears(Integer.parseInt(toStr)); } while (start.isBefore(end)) { final DropDownPosition pos = getDropDownPosition(_parameter, start.getYear(), start.getYear()); pos.setSelected(start.getYear() == new DateTime().getYear()); positions.add(pos); start = start.plusYears(1); } break; } final Return ret = new Return(); ret.put(ReturnValues.VALUES, positions); return ret; }
From source file:memoryaid.SetReminderController.java
@FXML private void handleSetReminderBtnAction(ActionEvent event) throws Exception { System.out.println("You clicked Add Reminder!"); String rType = (String) reminderTypeBox.getValue(); String rName = reminderNameText.getText(); LocalDate rSDate = startDateId.getValue(); LocalDate rEDate = endDateId.getValue(); List<LocalDate> reminderDates = new ArrayList<>(); String hours = (String) reminderHhBox.getValue(); String minutes = (String) reminderMmBox.getValue(); String seconds = (String) reminderSsBox.getValue(); ObservableList<String> repeat = multiSelectComboBox.getCheckModel().getCheckedItems(); String imgPath = imagePathText.getText(); if (rType == null || rName == null || rSDate == null || rEDate == null || hours == null || minutes == null || seconds == null || repeat.size() == 0 || imgPath == null) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Oops, an Error Dialog"); alert.setContentText("Please fill all the fields"); alert.showAndWait();/* ww w .ja v a 2 s .c o m*/ System.out.println("Please fill all the fields"); } else if (rSDate.isAfter(rEDate) == true) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Oops, an Error Dialog"); alert.setContentText("End date cannot be before the Start date"); alert.showAndWait(); System.out.println("End date should be greater than start date"); } else { String rTime = hours + ":" + minutes + ":" + seconds; if (rType != null && rName != null && !rName.isEmpty() && rEDate != null && hours != null && minutes != null && seconds != null && repeat != null && imgPath != null) { String destinationPath = "/Users/madhaviunnam/NetBeansProjects/MemoryAid/src/Reminders"; File destinationPathObject = new File(destinationPath + "/" + rName + ".png"); File sourceFilePathObject = new File(imgPath); FileUtils.copyFile(sourceFilePathObject, destinationPathObject); System.out.println( "You clicked Add Reminder!" + rType + rName + rSDate + rEDate + rTime + repeat + imgPath); System.out.println("****Inside if"); Reminder reminderToSet = new Reminder(); reminderToSet.setReminderName(rName); reminderToSet.setReminderType(rType); reminderToSet.setStartDate(rSDate); reminderToSet.setEndDate(rEDate); //endDateToCheck = rEDate.plusDays(1); if (repeat.contains("Every Monday")) { reminderToSet.setRepeatMon("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.MONDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } rSDate = startDateId.getValue(); } else { reminderToSet.setRepeatMon("false"); } if (repeat.contains("Every Tuesday")) { reminderToSet.setRepeatTue("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.TUESDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } rSDate = startDateId.getValue(); } else { reminderToSet.setRepeatTue("false"); } if (repeat.contains("Every Wednesday")) { reminderToSet.setRepeatWed("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.WEDNESDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } rSDate = startDateId.getValue(); } else { reminderToSet.setRepeatWed("false"); } if (repeat.contains("Every Thursday")) { reminderToSet.setRepeatThu("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.THURSDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } rSDate = startDateId.getValue(); } else { reminderToSet.setRepeatThu("false"); } if (repeat.contains("Every Friday")) { reminderToSet.setRepeatFri("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.FRIDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } rSDate = startDateId.getValue(); } else { reminderToSet.setRepeatFri("false"); } if (repeat.contains("Every Saturday")) { reminderToSet.setRepeatSat("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.SATURDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } rSDate = startDateId.getValue(); } else { reminderToSet.setRepeatSat("false"); } if (repeat.contains("Every Sunday")) { reminderToSet.setRepeatSun("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.SUNDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } } else { reminderToSet.setRepeatSun("false"); } if (repeat.contains("None")) { reminderToSet.setRepeatNone("true"); reminderDates.add(rSDate); } else { reminderToSet.setRepeatNone("false"); } System.out.println("%%%%Reminder DATes" + reminderDates); reminderToSet.setReminderTime(rTime); reminderToSet.setReminderStatus("New"); DbConnection db = new DbConnection(); Connection conn = db.connect(); PreparedStatement preparedStmt = null; String insertSql = "INSERT into Reminders(ReminderType, ReminderName, StartDate, EndDate, ReminderTime, RepeatM, RepeatT, RepeatW, RepeatTH, RepeatF, RepeatSat, RepeatSun)" + "values(?,?,?,?,?,?,?,?,?,?,?,?)"; preparedStmt = conn.prepareStatement(insertSql); preparedStmt.setString(1, reminderToSet.getReminderType()); preparedStmt.setString(2, reminderToSet.getReminderName()); preparedStmt.setString(3, reminderToSet.getStartDate().toString()); preparedStmt.setString(4, reminderToSet.getEndDate().toString()); preparedStmt.setString(5, reminderToSet.getReminderTime()); preparedStmt.setString(6, reminderToSet.getRepeatMon()); preparedStmt.setString(7, reminderToSet.getRepeatTue()); preparedStmt.setString(8, reminderToSet.getRepeatWed()); preparedStmt.setString(9, reminderToSet.getRepeatThu()); preparedStmt.setString(10, reminderToSet.getRepeatFri()); preparedStmt.setString(11, reminderToSet.getRepeatSat()); preparedStmt.setString(12, reminderToSet.getRepeatSun()); preparedStmt.executeUpdate(); System.out.println("Reminder Inserted Successfully "); //Get the inserted reminders RId String getRIdsql = "Select max(RId) as RId from Reminders"; ResultSet rSet = conn.createStatement().executeQuery(getRIdsql); int newRId = 0; while (rSet.next()) { newRId = rSet.getInt(1); } System.out.println("RID ^^^^^^^^" + newRId); PreparedStatement preparedStmtRDetails = null; for (int i = 0; i < reminderDates.size(); i++) { String rDetailsSql = "Insert into ReminderDetails(RId,DetailNum,ReminderDate,ReminderStatus)" + " values(?,?,?,?)"; preparedStmtRDetails = conn.prepareStatement(rDetailsSql); preparedStmtRDetails.setInt(1, newRId); preparedStmtRDetails.setInt(2, i); preparedStmtRDetails.setString(3, reminderDates.get(i).toString()); preparedStmtRDetails.setString(4, "New"); preparedStmtRDetails.executeUpdate(); System.out.println("ReminderDetails Table Insert Successfull "); } Parent setReminder = FXMLLoader.load(getClass().getResource("SetReminder.fxml")); Scene set_reminder_refresh_scene = new Scene(setReminder); Stage app_stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); app_stage.hide(); app_stage.setScene(set_reminder_refresh_scene); app_stage.show(); } else { System.out.println("Inside else"); //show alert Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Oops, an Error Dialog"); alert.setContentText("Please fill all the fields"); alert.showAndWait(); } } }