I need to convert a CALENDAR variable to DATE (to get date and time), so after that that DATE variable is saved in an SQLite table that has a DATETIME type.
Clarified this we begin by showing the SQLite table called "file", which I plan contains the data of the documents of a directory hosted on an FTP server
Now, the table is filled by reading the FTP directory and taking attributes from the files (using methods from the commons.net.ftp * libraries) here the code
public void cargarArchivos() {
Connection con=null;
FTPClient ftp=null;
try {
con=Conector.connect();
ftp=Conector_FTP.cliente();
FTPFile[] files = ftp.listFiles();
for (FTPFile file : files) {
if (file.isFile()) {
String name = file.getName();
long tamanio=file.getSize();
Calendar fecha=file.getTimestamp();
PreparedStatement st= con.prepareStatement("insert into archivo (nombre,tamanio,fechamod) VALUES (?,?,?);");
st.setString(1, name);
st.setDouble(2, tamanio);
st.setDate(3, fecha);
st.execute();
}
}
} catch (Exception e) {
// TODO: handle exception
}
}
The problem occurs when I want to pass the Calendar date variable and use it in a setDate to send it to the database as seen here
I already tried to pause it and several options that I found on the Internet and I can not send the variable to the database