After a lot of tries I didn't found a way to assign a date taken from sql to a LocalDate
variable in a pattern of ("MM-dd-hh"). I have defined a timestamp field(it goes from years to seconds) which I need to set a prenotation hour, day and month. What do you suggest?
public class Prenot {
private LocalDate date;
private Date datesql;
public Prenot(LocalDate date) {
this.date = date;
}
public LocalDate getDate() {
return this.date;
}
public void setDate(LocalDate date) {
this.date = date;
}
public static void visualizePrenot(Connection con,
ObservableList<Prenot> list) {
try {
Connessione connn = new Connessione();
FXMLDocumentController prova = new FXMLDocumentController();
connn.estabilishConn(prova.getUser(), prova.getPass());
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM prenotazione");
while (rs.next()) {
list.add(new Prenot(
rs.getDate("data").toLocalDate());
}
} catch (SQLException e) {
e.printStackTrace();
System.out.println(e);
}
}
}
edit: I focused the code to needs, Now what do you suggest, if I abandon the java.sql.Date, to get a TIMESTAMP value from a mysql db? And if so what do you think it's better to get, into another different getter, days and hours and show them in a TableView?