I have many users and they are located in different timezones. When a user changes some data (for instance edits) with her or his timezone, others must see it with their timezone. For this what can I do? Firstly , I need to save date with UTC timezone and when user wants to get it, It does request to api and gets returned date. After that user can convert this date with its timezone. Other users also do so. I think it works such
Asked
Active
Viewed 52 times
0
-
Let's assume you want to show lastUpdatedTime for every user, then have 2 fields persisted in the DB: the _lastUpdatedTime_ and _lastUpdatedTimezone_. _lastUpdatedTime_ will have time in UTC and _lastUpdatedTimezone_ will have the timezone of the user. Convert the UTC to user specific timezone when you return the data to frontEnd. – Aditya Narayan Dixit Sep 03 '18 at 12:02
-
1Possible duplicate of [Java Best Practice for Date Manipulation/Storage for Geographically Diverse Users](https://stackoverflow.com/questions/40075780/java-best-practice-for-date-manipulation-storage-for-geographically-diverse-user) – Ole V.V. Sep 03 '18 at 12:16
-
It sounds like you have already described the solution. So, what else are you asking for here? – Matt Johnson-Pint Sep 04 '18 at 17:56
1 Answers
0
In short:
- if you have to deal with daylight saving time (DST), you have to stick to
java.time.ZonedDateTime
- If you don't care about DST - use
java.time.OffsetDateTime
- In any case for all communications use ISO8601 standard

Max Farsikov
- 2,451
- 19
- 25