public long getNetworkTime() throws IOException {
    HttpURLConnection urlConnection = mUrlConnectionFactory.openHttpUrl(TIME_SOURCE_URL);
    urlConnection.setRequestMethod("HEAD");
    int responseCode = urlConnection.getResponseCode();
    if (responseCode != HttpURLConnection.HTTP_OK) {
      Log.d(LOG_TAG, String.format("URL %s returned %d", TIME_SOURCE_URL, responseCode));
      throw new IOException(String.format("HTTP status code %d", responseCode));
    }
    long date = urlConnection.getHeaderFieldDate(DATE_HEADER, 0);
    if (date == 0) {
      String dateHeader = urlConnection.getHeaderField(DATE_HEADER);
      throw new IOException("Got missing or invalid date from header value " + dateHeader);
    }
    Log.d(LOG_TAG, String.format("Got date value %d", date));
    return date;
  }
Gets the system time by issuing a request over the network.

@return time (milliseconds since epoch).

@throws IOException if an I/O error occurs.
java/com/google/android/apps/authenticator/timesync/NetworkTimeProvider.java