How to convert ZonedDateTime to Date?

后端 未结 9 700
无人共我
无人共我 2020-12-04 09:19

I am trying to set a server agnostic date time in my database and I believe the best practice to do so is to set a UTC DateTime. My db server is Cassandra and the db driver

9条回答
  •  生来不讨喜
    2020-12-04 10:16

    You can convert ZonedDateTime to an instant, which you can use directly with Date.

    Date.from(java.time.ZonedDateTime.now().toInstant());
    

提交回复
热议问题