Can any body tell me how can I store Java Date to Mysql datetime...?
When I am trying to do so...only date is stored and time remain 00:00:00 in Mysql date stores like this...
2009-09-22 00:00:00 I want not only date but also time...like
2009-09-22 08:08:11 I am using JPA(Hibernate) with spring mydomain classes uses java.util.Date but i have created tables using handwritten queries...
this is my create statement
CREATE TABLE ContactUs ( id BIGINT AUTO_INCREMENT, userName VARCHAR(30), email VARCHAR(50), subject VARCHAR(100), message VARCHAR(1024), messageType VARCHAR(15), contactUsTime DATETIME, PRIMARY KEY(id) );
java.util.Dateat all (in 2010 there probably was no better choice). Better to use the modern classes, likejava.time.Instantorjava.time.LocalDateTime, depending on the exact requirements for the date-time you need to store.