1 //Prevayler(TM) - The Free-Software Prevalence Layer. 2 //Copyright (C) 2001-2003 Klaus Wuestefeld 3 //This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 4 5 package org.prevayler.implementation.clock; 6 7 import java.util.Date; 8 9 /** A Clock that uses the local machine clock (System.currentTimeMillis()) as its time source. 10 */ 11 public class MachineClock extends BrokenClock { 12 13 /** @return The local machine time. 14 */ 15 public Date time() { 16 update(); 17 return super.time(); 18 } 19 20 21 private void update() { 22 long newTime = System.currentTimeMillis(); 23 if (newTime != _millis) advanceTo(new Date(newTime)); 24 } 25 26 } 27