From 802af115533039a0c8733e97dc36012effcd367c Mon Sep 17 00:00:00 2001 From: kohsuke Date: Sun, 29 Jul 2007 22:49:48 +0000 Subject: [PATCH] added an object to represent the clock difference. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3919 71c3de6d-444a-0410-be80-ed276b4c234a --- .../java/hudson/util/ClockDifference.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 core/src/main/java/hudson/util/ClockDifference.java 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 0000000000..06e3e1fb13 --- /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; + } +} -- GitLab