I want to store date in my DB table as dd-MM-yyyy HH:mm:ss.
Basically I want date and time also.
I used -
Java.sql.Date date = new Java.sql.Date(System.currentTimeMillis());
It is giving me date value in DB table field but not time..
what do I need to do for it?
1. I checked SimpleDateFormat. It does do the formatting but gives back String, I want a formatted Date object
2. Also, I checked to use java.sql.Timestamp - however it gives values till nano seconds, I want it till seconds only.
Dates in databases do not have formats, they are usually stored as numbers. The SQL type DATE does not store time information so you will need to use timestamp (or your database equivalient thereof). If yuo don't to display fractions beyond seconds just format the timestamp when you display it.