Search code examples
javatimestampjava-8localtimejava-time

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


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


Solution

  • 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.