Getting time from public time server
<p>I try to use the following code to obtain time from public time server.</p>

<pre><code>package aaa;

import java.util.Arrays;
import java.util.List;

import org.apache.commons.net.TimeTCPClient;

public final class Main
{
    public static java.util.Date getNTPDate() {
        List&lt;String&gt; hosts = Arrays.asList("0.pool.ntp.org");

        for (String host : hosts) {
            TimeTCPClient client = new TimeTCPClient();
            // We want to timeout if a response takes longer than 5 seconds
            client.setDefaultTimeout(5000);
            try {
                client.connect(host);
                java.util.Date ntpDate = client.getDate();
                client.disconnect();
                // Just to be extra caution.
                if (ntpDate != null) {
                    return ntpDate;
                }
            }
            catch (java.net.SocketException exp) {
                exp.printStackTrace();
            }
            catch (java.io.IOException exp) {
                exp.printStackTrace();
            }
        }
        return null;
    }

    public static final void main(String[] args)
    {
        System.out.println(getNTPDate());
    }

}
</code></pre>

<p>However, all the time, I am getting <code>java.net.ConnectException: Connection timed out: connect</code></p>

<p>I had tried to google for several different time server. However, non of them work. I was wondering, is the problem lies on my code, or the server I choose?</p>
