Date/Time between java and db (mysql)
Thanks for almighty StackOverflow, the answer is here : http://stackoverflow.com/questions/3323618/handling-mysql-datetimes-and-timestamps-in-java
The most error-prone part is:
In contrary toSo to retrieve both date and time of the record, the obvious wayjava.util.Date(whichcontains information about both the date and time parts), thejava.sql.Datecontains only information about the date part (year, month, day).
java.util.Date record_date = rs.getDate("record_date");doesn't work. It has to be:
java.util.Timestamp ts = rs.getTimestamp("record_date");
java.util.Date record_date = rs;
0 Comments:
<< Home