List of usage examples for org.apache.commons.net.time TimeUDPClient SECONDS_1900_TO_1970
long SECONDS_1900_TO_1970
To view the source code for org.apache.commons.net.time TimeUDPClient SECONDS_1900_TO_1970.
Click Source Link
From source file:it.greenvulcano.util.remotefs.RemoteManager.java
/** * Return current time on the remote FTP server. * // w w w. ja v a 2 s.c o m * @return the current time on the remote FTP server. */ public long getRemoteTime() { boolean useLocalTime = true; long time = -1; try { if (timeUdpClient == null) { timeUdpClient = new TimeUDPClient(); } timeUdpClient.setDefaultTimeout(1000); timeUdpClient.open(); time = (timeUdpClient.getTime(InetAddress.getByName(hostname)) - TimeUDPClient.SECONDS_1900_TO_1970) * 1000; timeUdpClient.close(); useLocalTime = false; } catch (Exception exc) { logger.warn("Could not detect server time: " + exc); time = System.currentTimeMillis(); } finally { logger.debug((useLocalTime ? "LOCAL" : "REMOTE") + " machine time [" + time + "]: " + new Date(time)); } return time; }