I am trying to insert java.util.Date
after converting it to java.sql.Timestamp and I am using the following snippet:
java.util.Date utilDate = new java.util.Date();
java.sql.Timestamp sq = new java.sql.Timestamp(utilDate.getTime());
But this is giving me sq
as 2014-04-04 13:30:17.533
Is there any way to get the output without milliseconds?
Take a look at
SimpleDateFormat
:You can cut off the milliseconds using a
Calendar
:Output:
This gives me the following output:
The problem is with the way you are printing the Time data
I suggest using DateUtils from apache.commons library.
Edit: Fixed
Calendar.MILISECOND
toCalendar.MILLISECOND