/** * Specify how far away from the "correct" time the computer is - a positive * value means that the system time is slow, while a negative value means the system time is fast. * * @param offsetMs the delta from System.currentTimeMillis() (NOT the delta from now()) */ public void setOffset(long offsetMs) { setOffset(offsetMs, false); }
public void setNow(long realTime) { if (realTime < BuildTime.getEarliestTime() || realTime > BuildTime.getLatestTime()) { Log log = getLog(); String msg = "Invalid time received: " + new Date(realTime); if (log.shouldWarn()) log.warn(msg, new Exception()); else log.logAlways(Log.WARN, msg); return; } long diff = realTime - System.currentTimeMillis(); setOffset(diff); }
public void timeReached() { // use the same % as in RouterClock so that check will never fail // This is their our offset w.r.t. them... long peerOffset = getFramedAveragePeerClockSkew(33); if (peerOffset == 0) return; long currentOffset = _context.clock().getOffset(); // ... so we subtract it to get in sync with them long newOffset = currentOffset - peerOffset; _context.clock().setOffset(newOffset); } }
_context.clock().setOffset(1000 * (0 - _peerSkew), true); _peerSkew = 0; if (diff != 0)
_context.clock().setOffset(1000 * (0 - _peerSkew), true); _peerSkew = 0; if (diff != 0)
_context.clock().setOffset(0 - skew, true); if (skew != 0) { _log.logAlways(Log.WARN, "NTP failure, UDP adjusting clock by " + DataHelper.formatDuration(Math.abs(skew)));