hoccer / hoccer-talk-spike

Android Client & Backend Software
0 stars 0 forks source link

Times in database not independent from timezone #1088

Open elRadish opened 8 years ago

elRadish commented 8 years ago

Java handles time independently from timezones as milliseconds from 1-1-1970 (Unix epoch time). Timezone are only used when formatting dates as strings.

All times are stored as local date-formatted strings in database. When reading times from database, they are interpreted as times in the current timezone and converted back to milliseconds.

Example of one delivery

Set time to 16:41 GMT +4 timeaccepted: 1450356109011 (=12:41:49 GMT / 16:41:49 GMT+4)

Saved as local time to database as "2015-12-17 16:41:49.011"

Set time to 13:44 GMT +1 -> restart and read back from database

Database time string is interpreted as local time: 1450366909011 (=15:41:49 GMT / 16:41:49 GMT+1)

Delivery is now 3h later!

But absolute time in milliseconds should never change.

elRadish commented 8 years ago

To keep backwards-compatibility, we can't change the way to store dates easily.

Ideas to fix:

-Save times to database in UTC and interpret accordingly: https://en.wikipedia.org/wiki/ISO_8601#UTC

-Save times in epoch time