List of usage examples for org.joda.time LocalDate toLocalDateTime
public LocalDateTime toLocalDateTime(LocalTime time)
From source file:propel.core.validation.propertyMetadata.LocalDatePropertyMetadata.java
License:Open Source License
/** * {@inheritDoc}/*from w ww. j a va 2 s. co m*/ */ public LocalDate validate(LocalDate value) throws ValidationException { if (value != null) { // use the existing validation method val result = validate(value.toLocalDateTime(LocalTime.MIDNIGHT)); if (result != null) return result.toLocalDate(); } else // check if null allowed, using the other validate() validate((LocalDateTime) null); return null; }
From source file:view.popups.shift.ShiftManualPopup.java
private void initButtons() { addShifts = new PopupMenuButton("Tilfj vagter"); addShifts.setOnAction(e -> {//from w ww.j ava2s . co m ArrayList<TimeInvestment> shifts = new ArrayList<>(); //Henter datoerne p de valgte ugedage, hvor hvert index passer til en ugedag //s mandag er index 0 osv. Hvis ugedagen ikke er valgt er indexet null. int weekCounter = 0; //Initialisere start slut time og minutvrdierne med ikke legitime tal int startHH = -1; int startMM = -1; int endHH = -1; int endMM = -1; //Tjekker om der er skrevet tekst i de fire tekstfields der skal indeholde //time og minutvrdi. String inputErrorMessage = "Der kan kun indtastes tal i de 4 felter"; try { startHH = Integer.parseInt(tStartHH.getText()); startMM = Integer.parseInt(tStartMM.getText()); endHH = Integer.parseInt(tEndHH.getText()); endMM = Integer.parseInt(tEndMM.getText()); } catch (NumberFormatException ex) { exceptionPopup.display(inputErrorMessage); } String wrongHourSize = "Der kan kun indtastes et validt timetal"; String wrongMinSize = "Der kan kun indtastes et validt Minuttal"; if (cWeek.getSelectionModel().getSelectedItem() == null) { exceptionPopup.display("Vlg en uge"); } else if (cEmployee.getSelectionModel().getSelectedItem() == null) { exceptionPopup.display("Vlg en ansat"); } else if (cRoom.getSelectionModel().getSelectedItem() == null) { exceptionPopup.display("Vlg et Rum"); } else if (!monday.isSelected() && !tuesday.isSelected() && !wednesday.isSelected() && !thursday.isSelected() && !friday.isSelected() && !saturday.isSelected() && !sunday.isSelected()) { exceptionPopup.display("Vlg mindst en dag p ugen"); } else if (startHH < 0 || startHH >= 24 || endHH < 0 || endHH >= 24) { exceptionPopup.display(wrongHourSize); } else if (startMM < 0 || startMM >= 60 || endMM < 0 || endMM >= 60) { exceptionPopup.display(wrongMinSize); } else { ArrayList<LocalDate> chosenDays = getCheckBoxLocalDate(); ArrayList<LocalDateTime> chosenDaysNTime = new ArrayList<>(); Hours hours = null; try { hours = getEndLocalHours(); } catch (Exception ex) { System.out.println(ex.getMessage()); } Minutes minutes = null; try { minutes = getEndLocalMinutes(); } catch (Exception ex) { System.out.println(ex.getMessage()); } LocalTime startTime = null; try { startTime = getStartLocalTime(); } catch (Exception ex) { System.out.println(ex.getMessage()); } if (hours != null || minutes != null || startTime != null) { Employee employee = (Employee) cEmployee.getValue(); Room room = (Room) cRoom.getValue(); for (LocalDate chosenDay : chosenDays) { if (chosenDay != null) { //Her omdannes alle LocalDates til LocalDateTimes og indsttes i chosenDaysNTime arrayet LocalDateTime dateToDateTime = chosenDay.toLocalDateTime(startTime); chosenDaysNTime.add(dateToDateTime); } } if (!chosenDaysNTime.isEmpty()) { for (LocalDateTime chosenDaysNTime1 : chosenDaysNTime) { TimeInvestment tm = new TimeInvestment(hours, minutes, chosenDaysNTime1, employee, room); shifts.add(tm); } } //TimeInvestmenthandler skal indstte dem i databasen. try { Xray.getInstance().getTimeInvestmentControl().addTimeInvestments(shifts); } catch (DatabaseException ex) { System.out.println(ex.getMessage()); } } else { exceptionPopup.display("Tidsperioden for vagten kunne ikke kalkuleres, " + "kontakt venligst systemadministratoren"); } } }); dayShift = new ImageButton("pictures/morgen 60.png", "pictures/morgen 60 dark.png"); dayShift.setOnAction(e -> { eveningShift.setUnPressed(); nightShift.setUnPressed(); tStartHH.setText("7"); tStartMM.setText("30"); tEndHH.setText("15"); tEndMM.setText("15"); }); eveningShift = new ImageButton("pictures/aften 60.png", "pictures/aften 60 dark.png"); eveningShift.setOnAction(e -> { dayShift.setUnPressed(); nightShift.setUnPressed(); tStartHH.setText("15"); tStartMM.setText("15"); tEndHH.setText("23"); tEndMM.setText("30"); }); nightShift = new ImageButton("pictures/nat 60.png", "pictures/nat 60 dark.png"); nightShift.setOnAction(e -> { dayShift.setUnPressed(); eveningShift.setUnPressed(); tStartHH.setText("23"); tStartMM.setText("30"); tEndHH.setText("7"); tEndMM.setText("30"); }); }