4 ms·
I am not using Java but I am right now making a booking system. I am storing local time (with Offset) and the timezone identifier such as "Europe/London". How
by Fifer82 9y ago
I am not using Java but I am right now making a booking system. I am storing local time (with Offset) and the timezone identifier such as "Europe/London".
How does using Day Count help?
- RegW 9y agoSorry for being oblique. A day count is just the number of days since some arbitary point. Say today is 42849, tomorrow is 42850, etc.. If the user enters the 24th April 2017, you store 42849. When you read it back 42849 is always displayed as 24th April 2017. There is no magic - you could just store 3 integers, or a formatted string say "20170424". Anything that doesn't involve timezones. Perhaps, with your programming language you don't get the same issues, but to use java.util.Date you have to parse this into a number of milliseconds since 1 Jan 1970. You might round it down to midnight at the start of the day - or the end. You might select midnight according to local time (with or without daylight saving), you might use UTC, or you might unwittingly leave it to the machine. To persist this to a DB you might use some ORM mapping like Hibernate - which without careful configuration may also make some assumptions about timezone, and Oracle might do the same. By the time the value is read back, your date may not be the same one entered - and this may not show up until you pass into daylight saving.
- Fifer82 9y agoNot at all, I was genuinely curious. Thanks for the detailed response, I understand what you were getting at.