Answer the question
In order to leave comments, you need to log in
How to compare two dates correctly?
From the server I receive time in timestamp, the last action of the user. The whole point is to determine whether the user is online or not.
Further, judging by the documentation, System.currentTimeMillis() returns the time since January 1, 1970 in milliseconds in UTC, and here the question arises, the time zone should not affect System.currentTimeMillis(), right?
//Получаю timestamp на устройстве
long timestamp = System.currentTimeMillis() / 1000L;
//Время когда пользователь перестанет быть онлайн
long online = latestAct+ 960L;
if(online > timestamp ){
//Онлайн
} else {
//Офлайн
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question