Anytime I have to handle dates/times in java it makes me sad
I'm trying to parse a string and turn it into a date object to insert in a preparepared statement. I've been trying to get this working but am having no luck. I also get the helpful error message when I go to compile the class.
"Exception in thread "main" java.lang.Error: Unresolved compilation problem: The method setDate(int, Date) in the type PreparedStatement is not applicable for the arguments (int, Date)"
Eh WTF?
Here is the offending code. for(int i = 0; i < flights.size(); i++){
String[] details = flight[i].toString().split(":");
DateFormat formatter ;
formatter = new SimpleDateFormat("ddMMyyyy");
Date date = formatter.parse(details[1]);
PreparedStatement pstmt = conn.prepareStatement(insertsql);
pstmt.setString(1, details[0]);
pstmt.setDate(2, date);
pstmt.setString(3, details[2] + "00");
pstmt.setString(4, details[3]);
pstmt.setString(5, details[4]);
pstmt.setString(6, details[5]);
pstmt.setString(7, details[6]);
pstmt.setString(8, details[7]);
pstmt.setString(9, details[8]);
pstmt.executeUpdate();
}