Add 10 minutes to the current timestamp in java with clipping milliseconds not working

I have the following code for finding the current timestamp in java

public static java.sql.Timestamp getCurrentJavaSqlTimestamp() {
                    java.util.Date date = new java.util.Date();
                    return new java.sql.Timestamp(date.getTime());
    }

And I call it using:

java.sql.Timestamp timestamp = getCurrentJavaSqlTimestamp();    
                System.out.println(timestamp);

I tried as follows: System.out.println(timestamp.getTime()+10*60*1000);

I am getting output as: 2015-12-03 14:30:56.350

I want add 10 minutes to this and I am expecting outputs as:

2015-12-03 14:40:56.350

Also I do not need milli seconds in each case.

What I finally expect is:2015-12-03 14:30:56 and 2015-12-03 14:40:56

Jon Skeet
people
quotationmark

It looks like all you want is a way of truncating a Timestamp to remove the milliseconds part. I believe that's as simple as:

timestamp.setNanos(0);

people

See more on this question at Stackoverflow