Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get current time from Google for Android? [closed]

Tags:

android

time

api

Is there a Google API to get current time from a timezone? If there is, how do I use it? I want to get current online time from a specific timezone, like getting "current time: 03/08/2015 11:27:54" or something like that. I want to get it from Google because of it confidence.

Thanks!

like image 212
IIRed-DeathII Avatar asked Sep 27 '22 03:09

IIRed-DeathII


1 Answers

This answer does well to give a method on how to do this. https://stackoverflow.com/a/13066298/2864560

Yahoo is just as reliable as Google in terms of small things like getting Time data, so this should not be so much of a hassle. You could get the time from Android (kinda like Google) by using this link: https://stackoverflow.com/a/8214204/2864560.

Another that would be reliable per user is this little piece of code

LocationManager locMan = (LocationManager) activity.getSystemService(activity.LOCATION_SERVICE);
long networkTS = locMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER).getTime();

That essentially gives you the time down to the second since it is using data that could be even more accurate than Google's

like image 92
Tobi Akerele Avatar answered Oct 13 '22 00:10

Tobi Akerele