@FXML private void saveNewMatch() throws RemoteException { if (validateInput()) { MatchDTO newMatch = new MatchDTOImpl(); newMatch.setDuration(_duration); Calendar cal = new GregorianCalendar(); cal.set( _localDate.getYear(), _localDate.getMonthValue(), _localDate.getDayOfMonth(), _localTime.getHour(), _localTime.getMinute(), _localTime.getSecond()); newMatch.setStart(cal.getTime()); MatchDTOImpl.SimpleMatchTeamDTO team1 = new MatchDTOImpl.SimpleMatchTeamDTO( _allTeamsTableView.getSelectionModel().getSelectedItem().getId()); team1.setId(_allTeamsOpponentTableView.getSelectionModel().getSelectedItem().getId()); team1.setName(_allTeamsTableView.getSelectionModel().getSelectedItem().getName()); team1.setVersion(_allTeamsTableView.getSelectionModel().getSelectedItem().getVersion()); MatchDTOImpl.SimpleMatchTeamDTO team2 = new MatchDTOImpl.SimpleMatchTeamDTO( _allTeamsOpponentTableView.getSelectionModel().getSelectedItem().getId()); team2.setId(_allTeamsOpponentTableView.getSelectionModel().getSelectedItem().getId()); team2.setName(_allTeamsOpponentTableView.getSelectionModel().getSelectedItem().getName()); team2.setVersion( _allTeamsOpponentTableView.getSelectionModel().getSelectedItem().getVersion()); newMatch.setTeam1(team1); newMatch.setTeam2(team2); newMatch.setTournamentId(_tournament.getId()); newMatch.setMatchStatus("Planned"); _tournament.addMatch(newMatch); initSuccessAlert(); // todo fix correct weiterleitung if (_newTournament) { SportifyGUI.getSharedMainApp().loadNewTournamentView(_tournament, _externalDisplayTeamDTOs); } else { SportifyGUI.getSharedMainApp().loadEditTournamentForm(_tournament); } } }
private static void useLocalDate() { LocalDate date = LocalDate.of(2014, 3, 18); int year = date.getYear(); // 2014 Month month = date.getMonth(); // MARCH int day = date.getDayOfMonth(); // 18 DayOfWeek dow = date.getDayOfWeek(); // TUESDAY int len = date.lengthOfMonth(); // 31 (days in March) boolean leap = date.isLeapYear(); // false (not a leap year) System.out.println(date); int y = date.get(ChronoField.YEAR); int m = date.get(ChronoField.MONTH_OF_YEAR); int d = date.get(ChronoField.DAY_OF_MONTH); LocalTime time = LocalTime.of(13, 45, 20); // 13:45:20 int hour = time.getHour(); // 13 int minute = time.getMinute(); // 45 int second = time.getSecond(); // 20 System.out.println(time); LocalDateTime dt1 = LocalDateTime.of(2014, Month.MARCH, 18, 13, 45, 20); // 2014-03-18T13:45 LocalDateTime dt2 = LocalDateTime.of(date, time); LocalDateTime dt3 = date.atTime(13, 45, 20); LocalDateTime dt4 = date.atTime(time); LocalDateTime dt5 = time.atDate(date); System.out.println(dt1); LocalDate date1 = dt1.toLocalDate(); System.out.println(date1); LocalTime time1 = dt1.toLocalTime(); System.out.println(time1); Instant instant = Instant.ofEpochSecond(44 * 365 * 86400); Instant now = Instant.now(); Duration d1 = Duration.between(LocalTime.of(13, 45, 10), time); Duration d2 = Duration.between(instant, now); System.out.println(d1.getSeconds()); System.out.println(d2.getSeconds()); Duration threeMinutes = Duration.of(3, ChronoUnit.MINUTES); System.out.println(threeMinutes); JapaneseDate japaneseDate = JapaneseDate.from(date); System.out.println(japaneseDate); }
@Test public void testTimerWidgetTriggered() throws Exception { Executors.newScheduledThreadPool(1) .scheduleAtFixedRate( new TimerWorker(holder.userDao, holder.sessionDao), 0, 1000, TimeUnit.MILLISECONDS); clientPair.appClient.send("deactivate 1"); verify(clientPair.appClient.responseMock, timeout(500)) .channelRead(any(), eq(new ResponseMessage(1, OK))); Timer timer = new Timer(); timer.id = 1; timer.x = 1; timer.y = 1; timer.pinType = PinType.DIGITAL; timer.pin = 5; timer.startValue = "dw 5 1"; timer.stopValue = "dw 5 0"; LocalTime localDateTime = LocalTime.now(ZoneId.of("UTC")); long curTime = localDateTime.getSecond() + localDateTime.getMinute() * 60 + localDateTime.getHour() * 3600; timer.startTime = curTime + 1; timer.stopTime = curTime + 2; DashBoard dashBoard = new DashBoard(); dashBoard.id = 1; dashBoard.name = "Test"; dashBoard.widgets = new Widget[] {timer}; clientPair.appClient.send("saveDash " + dashBoard.toString()); verify(clientPair.appClient.responseMock, timeout(500)) .channelRead(any(), eq(new ResponseMessage(2, OK))); clientPair.appClient.send("activate 1"); verify(clientPair.appClient.responseMock, timeout(500)) .channelRead(any(), eq(new ResponseMessage(3, OK))); verify(clientPair.hardwareClient.responseMock, timeout(2000)) .channelRead(any(), eq(produce(7777, HARDWARE, "dw 5 1"))); clientPair.hardwareClient.reset(); verify(clientPair.hardwareClient.responseMock, timeout(2000)) .channelRead(any(), eq(produce(7777, HARDWARE, "dw 5 0"))); }
public void setObject(ExecutionContext ec, PreparedStatement ps, int[] exprIndex, Object value) { if (value == null) { getDatastoreMapping(0).setObject(ps, exprIndex[0], null); } else if (datastoreMappings != null && datastoreMappings.length > 0 && datastoreMappings[0].isStringBased()) { TypeConverter conv = ec.getNucleusContext() .getTypeManager() .getTypeConverterForType(LocalTime.class, String.class); if (conv != null) { Object obj = conv.toDatastoreType(value); getDatastoreMapping(0).setObject(ps, exprIndex[0], obj); } else { throw new NucleusUserException("This type doesn't support persistence as a String"); } } else { LocalTime val = (LocalTime) value; Calendar cal = Calendar.getInstance(); cal.set(0, 0, 0, val.getHour(), val.getMinute(), val.getSecond()); getDatastoreMapping(0).setObject(ps, exprIndex[0], cal); } }
// ----------------------------------------------------------------------- private void check(LocalTime time, int h, int m, int s, int n) { assertEquals(time.getHour(), h); assertEquals(time.getMinute(), m); assertEquals(time.getSecond(), s); assertEquals(time.getNano(), n); }
/** @param time Zeit */ public void setValue(final LocalTime time) { hoursTextField.setText(getTwoDigitValue(time.getHour())); minutesTextField.setText(getTwoDigitValue(time.getMinute())); secondsTextField.setText(getTwoDigitValue(time.getSecond())); }
public static int getSecond(Time time) { LocalTime localTime = time.toLocalTime(); return localTime.getSecond(); }