The easiest way is something like:
long time = date.getTime();
date.setTime((time / 1000) * 1000);
In other words, clear up the last three digits of the millis since 1970 UTC.
I believe that it will also clear the nanosecond part if it is java.sql.Timestamp.
source
share