Reputation: 16920
I have a datetime field in mysql table and i am using JPA for persisting data but only date goes in database. Time always shows 00:00:00. What should i do?
I am not doing any manipulation with Date. All i do is to assign new Date()
to a variable and store it in database.
What am i doing wrong?
Upvotes: 1
Views: 87
Reputation: 9784
Example below:
private String getDateTime() {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date();
return dateFormat.format(date);
}
Tips like these can be found on http://www.java-tips.org
Upvotes: 1