• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps accessing atomic clock

kevingd

Lurker
Feb 10, 2010
1
0
I would like to be able to get the correct time for an application (my G1 is running on ATT, so with EDGE network the network time is not accurate).

I have tried the following code and do not get anything from the input stream even though a capture with wireshark shows the correct UTC time being returned.
If I set the URL to www.yahoo.com the input stream shows the yahoo html without any problem.
Does anyone know why I cannot read the input stream from one of the atomic server sites ?

// final String ATOMICTIME_SERVER="http://132.163.4.101:13";​
// final String ATOMICTIME_SERVER="http://www.yahoo.com";​
// NIST, Gaithersburg, Maryland (time-a.nist.gov)

final String ATOMICTIME_SERVER="http://129.6.15.28:13";

try {
System.
out.println("before connection");
URLConnection conn =
new URL(ATOMICTIME_SERVER).openConnection();

in = new BufferedReader
(
new InputStreamReader(conn.getInputStream()));

String inputLine;

while ((inputLine = in.readLine()) != null)
System.
out.println(inputLine);




Thanks in advance,

Kevin
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones