I am developing a Spring Boot app and there are some date/time fields in some entities. When considering an application will be used by multiple users from all around the world, the date and time fields should be treated properly and I am trying to follow one of the proper approach.
In this scene, what would you suggest to save date and time by users from different time zones. I think the following approaches:
I can save date and time based on UTC+0 and then when someone else retrieve data, I can show them based on their current time zone.
or save date and time based on the local time of the user with that local time zone.
I am really confused with this issue as I have no previous experience. And as far as I see, I can use LocalDateTime
of java.time
with Java 11+. But if you have another suggestion that is better than java.time
, you can share also.