How to convert java.sql.timestamp to LocalDate (java8) java.time?

simonides picture simonides · Apr 24, 2014 · Viewed 107.4k times · Source

In Java 8, how can I convert a Timestamp (in java.sql) to a LocalDate (in java.time)?

Answer

assylias picture assylias · Apr 24, 2014

You can do:

timeStamp.toLocalDateTime().toLocalDate();

Note that timestamp.toLocalDateTime() will use the Clock.systemDefaultZone() time zone to make the conversion. This may or may not be what you want.