This is part of my code:
Date currentDate = new Date();
SimpleDateFormat fmt = new SimpleDateFormat("dd.MM.yyyy");
String formatert = fmt.format(currentDate);
Date dato = fmt.parse((formatert),new java.text.ParsePosition(0));
The case is that I need to send a date from my app to a table in a MSSQL server via JDBC.
The problem is that I get the following message when executing my sql statement:Syntax error converting datetime from character string. I understand that the format of my date has to be the same as in the db and my simpledateformat should fix that. But after I parse the string to get a date the format is all wrong. I thought the setLenient(false) would ensure that my format stays unaltered. What am I doing wrong??