Skip to content

Instantly share code, notes, and snippets.

View raghavsatyadev's full-sized avatar
🏠
Freelancing

Raghav Satyadev raghavsatyadev

🏠
Freelancing
View GitHub Profile
@raghavsatyadev
raghavsatyadev / RoomDBBug.md
Created March 9, 2025 11:19
Bug in Room DB for date field

I'm encountering a weird bug with Room Database.

I have two fields in my model: localUpdateDateTime and serverUpdateDateTime, which I use for syncing data with the cloud.

The issue is that I am not saving the local time to the Firebase server, so I need to update it every time there's a write operation from the code or when retrieving data from the cloud. When I fetch data from the cloud, I simply set the local date equal to the server date.

However, I’ve noticed that when I debug right before inserting or updating the data in the Room Database, both dates appear to be the same. But after I add this data to Room, there seems to be a difference between values.

codeTime=Sun Mar 09 16:41:15 GMT+05:30 2025 dbLocal=Sun Mar 09 16:41:15 GMT+05:30 2025 (There is a slight diff in milliseconds)