java – Android System.currentTimeMillis() value is different on firebase database than generated on app logcat
I am submitting a user last seen on Firebase Realtime Database and before setting value at firebase database i am generating a log with timestamp by System.currentTimeMillis()
but when i compare it with logcat and database timestamp it submitting a different timestamp on server.
Look at the logcat it shows the correct timestamp and it should be on server too
Disconnect with firebase server
Offline Time 5:01 pm 1639308715905
Firebase Realtime Database Value of Timestamp
1639308009264
Both Values are different that’s how i get wrong last seen of user
1639308715905 - App one
1639308009264 - Server One
The code i am using for log and to set value on server.
String offlineTime = String.valueOf(System.currentTimeMillis());
Log.d(TAG,"Offline Time "+App_Functions.getLocalDeviceTimestamp(Long.parseLong(offlineTime))+ " "+offlineTime);
lastOnline.onDisconnect().setValue(offlineTime);
Read more here: Source link