Date and Time Update to check if it is online

1

In my android app I have a service that sends from time to time a user location and saves in another field lastUpdate the day and time the update happened. I currently use Calendar.getInstance().getTime() to get the Date and send it to the database, but what I realize is that the time for many is sometimes earlier than the current time, what do I do to standardize?

    
asked by anonymous 27.01.2016 / 02:55

1 answer

1

For everything to work as you intended, the device receiving the date must be synchronized with the machine where the server is. There is no way around this.

The Calendar.getInstance().getTime() depends on the date and time of the android device.

However if you already do some type of synchronization and the error happens on a reduced scale I advise you to use System.currentTimeMillis(); to make the comparisons.

    
27.01.2016 / 16:47