Converting ZonedDateTime to string

前端 未结 2 1193
抹茶落季
抹茶落季 2021-01-25 06:20

I need to store the current time as a String in a database. The time can be in different timezones, so I\'m looking at using Java SE 8\'s new ZonedDateTime class.

I noti

2条回答
  •  抹茶落季
    2021-01-25 06:50

    Yes, that will accurately store the date, and using the .parse() method will allow you to use the other methods of ZoneDateTime. Though if you want to be able to use sorting functions with your db then you will need to either manually convert the ZonedDateTime into a timestamp or use your ORM's features to do it for you.

提交回复
热议问题