List of usage examples for org.joda.time LocalDateTime parse
@FromString public static LocalDateTime parse(String str)
From source file:technicalServices.persistence.QualificationHandler.java
public ArrayList<CourseQualification> getCourseQualifications() throws DatabaseException { ArrayList<CourseQualification> courseQualifications = new ArrayList<>(); try {/*from www . j a v a 2s . c om*/ Statement stmt = DatabaseConnection.getInstance().getConnection().createStatement(); String SQL = "select * from courseQualification, qualification where " + "courseQualification.id = qualification.id;"; ResultSet rs = stmt.executeQuery(SQL); while (rs.next()) { int id = rs.getInt("qualification.id"); String type = rs.getString("type"); int limit = rs.getInt("limit"); LocalDateTime localDateStart = LocalDateTime.parse(rs.getString("localDateStart")); LocalDateTime localDateEnd = LocalDateTime.parse(rs.getString("localDateEnd")); Statement stmtEmployees = DatabaseConnection.getInstance().getConnection().createStatement(); String sql = "select * from qualToEmp where qualId = " + id; ArrayList<Employee> qualEmployees = new ArrayList<>(); ResultSet rsEmployees = stmtEmployees.executeQuery(sql); while (rsEmployees.next()) { int empId = rsEmployees.getInt("employeeNr"); qualEmployees.add(EmployeeHandler.getInstance().getEmployee(empId)); } stmtEmployees.close(); rsEmployees.close(); Statement stmtRooms = DatabaseConnection.getInstance().getConnection().createStatement(); sql = "select * from qualToRoom where qualId = " + id; ArrayList<Room> qualRooms = new ArrayList<>(); ResultSet rsRooms = stmtRooms.executeQuery(sql); while (rsRooms.next()) { String roomName = rsRooms.getString("roomName"); qualRooms.add(RoomHandler.getInstance().getRoom(roomName)); } stmtRooms.close(); rsRooms.close(); courseQualifications.add(new CourseQualification(id, type, qualEmployees, qualRooms, limit, localDateStart, localDateEnd)); } stmt.close(); rs.close(); return courseQualifications; } catch (SQLException ex) { throw new DatabaseException("Der kunne ikke hentes nogle kursus kvalifikationer fra databasen"); } }
From source file:technicalServices.persistence.TimeInvestmentHandler.java
public ArrayList<TimeInvestment> getUnassignedTimeInvestments() throws DatabaseException { ArrayList<TimeInvestment> timeInvestments = new ArrayList<>(); try {/* w ww . jav a2 s. c om*/ Statement stmt = DatabaseConnection.getInstance().getConnection().createStatement(); //Hent eller timeInvestment-objekter hvor rum-linket er null. String sql = "select * from timeInvestment where roomName is null;"; ResultSet rs = stmt.executeQuery(sql); while (rs.next()) { int id = rs.getInt("id"); Employee emp = EmployeeHandler.getInstance().getEmployee(rs.getInt("employeeNr")); Hours hours = Hours.hours(rs.getInt("hours")); Minutes minutes = Minutes.minutes(rs.getInt("minutes")); LocalDateTime startTime = LocalDateTime.parse(rs.getString("startTime")); timeInvestments.add(new TimeInvestment(id, hours, minutes, startTime, emp, null)); } return timeInvestments; } catch (SQLException ex) { throw new DatabaseException("Der kunne ikke hentes utildelte vagter fra databasen."); } }
From source file:technicalServices.persistence.TimeInvestmentHandler.java
public ArrayList<TimeInvestment> getAssignedTimeInvestments() throws DatabaseException { ArrayList<TimeInvestment> timeInvestments = new ArrayList<>(); try {/*from ww w . j av a 2 s . c o m*/ Statement stmt = DatabaseConnection.getInstance().getConnection().createStatement(); //Hent eller timeInvestment-objekter hvor rum-linket er null. String sql = "select * from timeInvestment where roomName is not null;"; ResultSet rs = stmt.executeQuery(sql); while (rs.next()) { int id = rs.getInt("id"); Employee emp = EmployeeHandler.getInstance().getEmployee(rs.getInt("employeeNr")); Hours hours = Hours.hours(rs.getInt("hours")); Minutes minutes = Minutes.minutes(rs.getInt("minutes")); LocalDateTime startTime = LocalDateTime.parse(rs.getString("startTime")); Room room = RoomHandler.getInstance().getRoom(rs.getString("roomName")); timeInvestments.add(new TimeInvestment(id, hours, minutes, startTime, emp, room)); } return timeInvestments; } catch (SQLException ex) { throw new DatabaseException("Der kunne ikke hentes tildelte vagter fra databasen."); } }