我使用下面的代碼來連接和從Android設備檢索從AtomicTime服務器UTC時間:獲得原子時間與Android
public static final String ATOMICTIME_SERVER="http://132.163.4.101:13";
BufferedReader in = null;
try
{
URLConnection conn = new URL(ATOMICTIME_SERVER).openConnection();
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String atomicTime;
while (true)
{
if ((atomicTime = in.readLine()).indexOf("*") > -1)
{
break;
}
}
... do something
}
catch ...
它不返回任何數據。當從瀏覽器訪問的網址,我們得到如下:
55884 11-11-19 07:40:22 00 0 0 824.5 UTC(NIST)
誰能幫助?
感謝praetorian droid – user1051566