I am developing one GPS Application. Which will send the location data to server for every one hour.
In this I am using following code:
location.getLatitude();
location.getLongitude();
location.getTime();
with this code I am getting Latitude and Longitude correctly and Time also, but I am getting some 13 digits number instead of the time. I done some research on that, I found that is an seconds for of the current time.
so now I need to convert that 13 digit number in to the specific format.
Location#getTime()returns “the UTC time of this fix, in milliseconds since January 1, 1970.”This is exactly the same behavior as
java.util.Date#getTime(). I’m not clear on what you’d like to do with this time data, but if you’d like to convert theLocation‘s time into ajava.util.Date, you can do it like this:Now it is somewhat easier to work with. If you’d like to create a particular string output format of that date, use
SimpleDateFormat:That said, if all you’d like to do is get the current time (which is what it sounds like you’re trying to do) you don’t need a
Locationat all:That’s it!
Does that help? If not, could you clarify what you’re trying to do?