List of usage examples for java.sql Time toLocalTime
@SuppressWarnings("deprecation") public LocalTime toLocalTime()
From source file:Main.java
public static LocalTime toLocalTime(java.sql.Time time) { return time.toLocalTime(); }
From source file:jef.tools.DateUtils.java
/** * Converts Time to LocalTime (null safety) * @param time//from ww w . ja v a 2 s. c om * @return LocalTime */ public static LocalTime toLocalTime(java.sql.Time time) { return time == null ? null : time.toLocalTime(); }
From source file:fll.scheduler.TournamentSchedule.java
/** * Load a tournament from the database./* w ww. j a v a2 s .c o m*/ * * @param connection * @param tournamentID * @throws SQLException */ public TournamentSchedule(final Connection connection, final int tournamentID) throws SQLException { final Tournament currentTournament = Tournament.findTournamentByID(connection, tournamentID); name = currentTournament.getName(); PreparedStatement getSched = null; ResultSet sched = null; PreparedStatement getPerfRounds = null; ResultSet perfRounds = null; PreparedStatement getNumRounds = null; ResultSet numRounds = null; PreparedStatement getSubjective = null; ResultSet subjective = null; PreparedStatement getSubjectiveStations = null; ResultSet stations = null; try { getSubjectiveStations = connection .prepareStatement("SELECT DISTINCT name from sched_subjective WHERE tournament = ?"); getSubjectiveStations.setInt(1, tournamentID); stations = getSubjectiveStations.executeQuery(); while (stations.next()) { final String name = stations.getString(1); subjectiveStations.add(name); } SQLFunctions.close(stations); stations = null; SQLFunctions.close(getSubjectiveStations); getSubjectiveStations = null; getNumRounds = connection .prepareStatement("SELECT MAX(round) FROM sched_perf_rounds WHERE tournament = ?"); getNumRounds.setInt(1, tournamentID); numRounds = getNumRounds.executeQuery(); if (numRounds.next()) { this.numRounds = numRounds.getInt(1) + 1; } else { throw new RuntimeException("No rounds found for tournament: " + tournamentID); } getSched = connection.prepareStatement("SELECT team_number, judging_station" + " FROM schedule"// + " WHERE tournament = ?"); getSched.setInt(1, tournamentID); getPerfRounds = connection.prepareStatement("SELECT round, perf_time, table_color, table_side" // + " FROM sched_perf_rounds" // + " WHERE tournament = ? AND team_number = ?" // + " ORDER BY round ASC"); getPerfRounds.setInt(1, tournamentID); getSubjective = connection.prepareStatement("SELECT name, subj_time" // + " FROM sched_subjective" // + " WHERE tournament = ? AND team_number = ?"); getSubjective.setInt(1, tournamentID); sched = getSched.executeQuery(); while (sched.next()) { final int teamNumber = sched.getInt(1); final String judgingStation = sched.getString(2); final TeamScheduleInfo ti = new TeamScheduleInfo(this.numRounds, teamNumber); ti.setJudgingGroup(judgingStation); getSubjective.setInt(2, teamNumber); subjective = getSubjective.executeQuery(); while (subjective.next()) { final String name = subjective.getString(1); final Time subjTime = subjective.getTime(2); ti.addSubjectiveTime(new SubjectiveTime(name, subjTime.toLocalTime())); } getPerfRounds.setInt(2, teamNumber); perfRounds = getPerfRounds.executeQuery(); int prevRound = -1; while (perfRounds.next()) { final int round = perfRounds.getInt(1); if (round != prevRound + 1) { throw new RuntimeException( "Rounds must be consecutive and start at 1. Tournament: " + tournamentID + " team: " + teamNumber + " round: " + (round + 1) + " prevRound: " + (prevRound + 1)); } final LocalTime perfTime = perfRounds.getTime(2).toLocalTime(); final String tableColor = perfRounds.getString(3); final int tableSide = perfRounds.getInt(4); if (tableSide != 1 && tableSide != 2) { throw new RuntimeException("Tables sides must be 1 or 2. Tournament: " + tournamentID + " team: " + teamNumber); } final PerformanceTime performance = new PerformanceTime(perfTime, tableColor, tableSide); ti.setPerf(round, performance); prevRound = round; } final String eventDivision = Queries.getEventDivision(connection, teamNumber, tournamentID); ti.setDivision(eventDivision); final Team team = Team.getTeamFromDatabase(connection, teamNumber); ti.setOrganization(team.getOrganization()); ti.setTeamName(team.getTeamName()); cacheTeamScheduleInformation(ti); } } finally { SQLFunctions.close(stations); stations = null; SQLFunctions.close(getSubjectiveStations); getSubjectiveStations = null; SQLFunctions.close(sched); sched = null; SQLFunctions.close(getSched); getSched = null; SQLFunctions.close(perfRounds); perfRounds = null; SQLFunctions.close(getPerfRounds); getPerfRounds = null; SQLFunctions.close(numRounds); numRounds = null; SQLFunctions.close(getNumRounds); getNumRounds = null; SQLFunctions.close(subjective); subjective = null; SQLFunctions.close(getSubjective); getSubjective = null; } }