i have three time server,time-nw.nist.gov, time1.ucla.edu ,time.ien.it now how can i get current time for all this server in java/android?
Asked
Active
Viewed 1,104 times
-1
-
possible duplicate of [use of ntp service](http://stackoverflow.com/questions/7677674/use-of-ntp-service) – Snicolas Apr 06 '12 at 10:01
1 Answers
1
Check Apache Commons Net library
https://commons.apache.org/net/
From their example:
public static final void timeTCP(String host) throws IOException
{
TimeTCPClient client = new TimeTCPClient();
try {
// We want to timeout if a response takes longer than 60 seconds
client.setDefaultTimeout(60000);
client.connect(host);
System.out.println(client.getDate());
} finally {
client.disconnect();
}
}

jordeu
- 6,711
- 1
- 19
- 19