开发者

gps time vs device time

I create a GPS tracking, but when I use DDMS to send coord开发者_开发技巧inate to the emulator and I want to get time of this coordinate through

Date date = new Date(gpsPos.getTime_stamp());   //gpsPos is an obj      
gpsPos.setDate_time(date.toString());               

The time I got from the function in miliseconds and I converted it to date using date class in java, but the date I got from converted is different from the real date of device.

How can i get the time location equals real time ? any idea? thx

what is the different between date.toString() and date.toGMTString()?

EDIT:

how can we solve it i want my gps time is equal to the real time (logic enough) in order to use it test sth later?


Date(milliSeconds) will create the Date object based on GMT, Date.toString will create a string based on your locale (by default but can be modified). If the milliseconds you used to create the Date object is actually based on your Locale then your time will be off by 4 hours if you're in EDT as an example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜