Location.getTime() returning a future time.
- by fiXedd
The following code:
// get the last known location
Criteria c = new Criteria();
c.setAccuracy(Criteria.ACCURACY_FINE);
Location lastKnown = mLocationManager.getLastKnownLocation(mLocationManager.getBestProvider(c, true));
// compare times
long currentTime = System.currentTimeMillis();
long gpsTime = lastKnown.getTime();
long age = (currentTime - gpsTime) / 1000;
Gives me:
currentTime = 1270062152738
gpsTime = 1270085378000
age = -23225
If you'll notice, it's returning the last location fix's time as a time in the future. Why is this happening?
EDIT:
From Location.getTime() :
Returns the UTC time of this fix, in milliseconds since January 1, 1970.
From System.currentTimeMillis() :
Returns the current system time in milliseconds since January 1, 1970 00:00:00 UTC. This method shouldn't be used for measuring timeouts or other elapsed time measurements, as changing the system time can affect the results.