import com.ezjavabeans.ezclock.*; import java.util.Date; import java.text.SimpleDateFormat; /** EzClock Example : Queries time from a time server (Atomic clock) * and prints it */ public class Clock { EzClock ezClock = new EzClock(); /** Default Constructor */ public Clock() { } /** Query the time server and prints the current time */ public static void main(String[] args) { try{ Clock clock = new Clock(); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); clock.ezClock.setTimeServer("time-b.nist.gov"); clock.ezClock.setTimePort(37); Date currentTime = clock.ezClock.getLocalTime(); System.out.println("Atomic time : " + sdf.format(currentTime)); }catch(EzClockException ex){ System.out.println(ex.getMessage()); } } }