dcsimg

How do I convert a java.sql.Timestamp to a java.util.Date?

John Zukowski

While Timesteamp extends Date, it stores the fractional part of the time within itself instead of within the Date superclass. If you need the partial seconds, you have to add them back in.


Date date = new Date(ts.getTime() + (ts.getNanos() / 1000000 ));