Am using a jcalendarcombo on a simple interface where a user can pick a date. when i try to save the date to a Db i get an error like this "com.MySQL.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: 'Tue Jul 16 12:06:25 EAT 2013' for column 'date_dispensed' at row 1" and i know its because of the difference in date formats.
Asked
Active
Viewed 970 times
1 Answers
0
The JCalendar
Component uses a Date
or DateTime
of type java.util.date
, and to save it in a database, you need to convert it to a java.sql.date
.
You can do something like this:
java.sql.date date = new java.sql.date(jCalendar.getDate().getTime());
and save the object date in your date_dispensed
.