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

前端 未结 3 651
后悔当初
后悔当初 2020-12-23 20:12

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

3条回答
  •  悲&欢浪女
    2020-12-23 20:47

    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.

提交回复
热议问题