-1

我有三个时间服务器,time-nw.nist.gov,time1.ucla.edu,time.ien.it 现在我如何在 java/android 中获取所有这些服务器的当前时间?

4

1 回答 1

1

检查 Apache Commons Net 库

https://commons.apache.org/net/

从他们的例子

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();
    }
}
于 2012-04-06T10:04:47.017 回答