Question: 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?

Answer: 
I suggest using DateUtils from apache.commons library.

```
long millis = DateUtils.truncate(utilDate, Calendar.MILLISECOND).getTime();
java.sql.Timestamp sq = new java.sql.Timestamp(millis );

```

Edit: Fixed `Calendar.MILISECOND` to `Calendar.MILLISECOND`
```
java.util.Date utilDate = new java.util.Date();
java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
System.out.println("utilDate:" + utilDate);
System.out.println("sqlDate:" + sqlDate);

```

This gives me the following output:

```
 utilDate:Fri Apr 04 12:07:37 MSK 2014
 sqlDate:2014-04-04

```