I'm looking for guidance on good practices of carrying dates as numeric timestamps using Spring Boot. Is there any?
A quite some time ago I used to work on the specific project using Spring on the backend. The system supposed to work across multiple timezones. Therefore it was decided to use integer values (Long) to store and transfer dates between backend and the web app. As I remember the main reason was to simplify and minimize work with timezones since the timestamp will always represent exact time and we always able to retrieve Date from it without worrying of incorrect timezone (the user's browser will apply proper timezone).
At that time I was little occupied with architecture, as I was only a junior. But since then I have not seen any application of this practice, and I can not find anything on the Internet.
I know there are some cases when we do not need to rely on time zones, for example when I travel to different country I don't want my alarm clock to be changed according to the new timezone. But I still want my reminder to notify me when I need to make an important call at the right time. I believe the second case is much more common in the software.
Therefore I wanted to know is there any real benefit of using numeric timestamps?
I see at least two potential benefits:
- Less hassle with the timezones (especially for the less experienced devs who can be confused at times working with dates)
- Less data is transferred through the REST (?)
Downsides:
- We have to extract Date value every time to process or display it (this can be automated using most of the frontend frameworks)
- Database values and server debugging is not that self-evident
Aucun commentaire:
Enregistrer un commentaire