//#
//# Corba Time Server
//# $Revision: 1.1 $
//# Copyright 2004 by Eric Y. Theriault
//# All Rights Reserved.
//# http://www.eyt.ca/CORBA
//#
package ca.eyt.corba;

/**
 * Implements the time server.
 */
public class TimeImpl extends ca.eyt.corba.corba.TimePOA {
   /**
    * Reference to the ORB
    */
   org.omg.CORBA.ORB orb;

   /**
    * Constructs a default implementation.
    */
   TimeImpl() {
   }

   /**
    * Sets the referencing ORB.
    */
   public void setORB( org.omg.CORBA.ORB orb ) {
      this.orb = orb;
   }

   /**
    * Acquire the time.
    * @return The current time.
    */
   public ca.eyt.corba.corba.TimeOfDay getTime() {
      // Get the date...
      java.util.Calendar date = java.util.Calendar.getInstance();
      short hour = (short)date.get( java.util.Calendar.HOUR );
      short minute = (short)date.get( java.util.Calendar.MINUTE );
      short second = (short)date.get( java.util.Calendar.SECOND );

      return new ca.eyt.corba.corba.TimeOfDay( hour, minute, second );
   }
};

