我有三个时间服务器,time-nw.nist.gov,time1.ucla.edu,time.ien.it 现在我怎样才能获得java / android中所有这个服务器的当前时间?
答案 0 :(得分:1)
检查Apache Commons Net库
https://commons.apache.org/net/
来自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();
}
}