I seached for a solution for converting a Calendar-object to a java.sql.date for inserting it into a MySQL DB (DateTime). I know this question is a FAQ. The solution I found is the following code:
java.sql.Date sqlDate = new java.sql.Date(cal.getTime().getTime() );
When i do a print of the sqlDate to the console I get:
sqlDate: 2005-06-27
But when I look into de DB I get the following date:
27/05/1905
I know that in Java the months are starting from 0-�11 and that the years counting is starting from 1900. But I assume that the solution is not to just add the correct month and year manually. because I get a correct console-output. If I do this I get a correct DB Date, but a wrong console-date.