diff --git a/core/src/main/java/hudson/util/ClockDifference.java b/core/src/main/java/hudson/util/ClockDifference.java new file mode 100644 index 0000000000000000000000000000000000000000..06e3e1fb13c0a67b063f6e4e2d34aac8b90a9fec --- /dev/null +++ b/core/src/main/java/hudson/util/ClockDifference.java @@ -0,0 +1,53 @@ +package hudson.util; + +import hudson.Util; + +/** + * Represents a clock difference. Immutable. + * + * @author Kohsuke Kawaguchi + */ +public final class ClockDifference { + /** + * The difference in milliseconds. + * + * Positive value means the slave is behind the master, + * negative value means the slave is ahead of the master. + */ + public final Long diff; + + public ClockDifference(long value) { + this.diff = value; + } + + /** + * Returns true if the difference is big enough to be considered dangerous. + */ + public boolean isDangerous() { + return Math.abs(diff)>5000; + } + + /** + * Gets the clock difference in HTML string. + */ + public String toString() { + if(-1000"; + return s; + } +}