equal
deleted
inserted
replaced
66 |
66 |
67 private long kerberosTime; // milliseconds since epoch, a Date.getTime() value |
67 private long kerberosTime; // milliseconds since epoch, a Date.getTime() value |
68 private int microSeconds; // the last three digits of the microsecond value |
68 private int microSeconds; // the last three digits of the microsecond value |
69 |
69 |
70 // The time when this class is loaded. Used in setNow() |
70 // The time when this class is loaded. Used in setNow() |
71 private static final long initMilli = System.currentTimeMillis(); |
71 private static long initMilli = System.currentTimeMillis(); |
72 private static final long initMicro = System.nanoTime() / 1000; |
72 private static long initMicro = System.nanoTime() / 1000; |
73 |
73 |
74 private static long syncTime; |
74 private static long syncTime; |
75 private static boolean DEBUG = Krb5.DEBUG; |
75 private static boolean DEBUG = Krb5.DEBUG; |
76 |
76 |
77 public static final boolean NOW = true; |
77 public static final boolean NOW = true; |
210 temp.setTime(temp.getTime()); |
210 temp.setTime(temp.getTime()); |
211 return temp; |
211 return temp; |
212 } |
212 } |
213 |
213 |
214 public void setNow() { |
214 public void setNow() { |
215 long microElapsed = System.nanoTime() / 1000 - initMicro; |
215 long newMilli = System.currentTimeMillis(); |
216 setTime(initMilli + microElapsed/1000); |
216 long newMicro = System.nanoTime() / 1000; |
217 microSeconds = (int)(microElapsed % 1000); |
217 long microElapsed = newMicro - initMicro; |
|
218 long calcMilli = initMilli + microElapsed/1000; |
|
219 if (calcMilli - newMilli > 100 || newMilli - calcMilli > 100) { |
|
220 if (DEBUG) { |
|
221 System.out.println("System time adjusted"); |
|
222 } |
|
223 initMilli = newMilli; |
|
224 initMicro = newMicro; |
|
225 setTime(newMilli); |
|
226 microSeconds = 0; |
|
227 } else { |
|
228 setTime(calcMilli); |
|
229 microSeconds = (int)(microElapsed % 1000); |
|
230 } |
218 } |
231 } |
219 |
232 |
220 public int getMicroSeconds() { |
233 public int getMicroSeconds() { |
221 Long temp_long = new Long((kerberosTime % 1000L) * 1000L); |
234 Long temp_long = new Long((kerberosTime % 1000L) * 1000L); |
222 return temp_long.intValue() + microSeconds; |
235 return temp_long.intValue() + microSeconds; |