package timeservice;

import java.rmi.*;
import java.rmi.server.*;
import java.util.*;

public class TimeServiceImpl extends UnicastRemoteObject implements TimeService 
{
  public TimeServiceImpl() throws RemoteException { }

  public String getTime() throws RemoteException
  {
    GregorianCalendar cal = new GregorianCalendar();
    StringBuffer sb = new StringBuffer();
    sb.append(cal.get(Calendar.HOUR_OF_DAY));
    sb.append(":" + cal.get(Calendar.MINUTE));
    sb.append(":" + cal.get(Calendar.SECOND));
    return sb.toString();
  }

  public TimeStore storeTime(TimeStore store) throws RemoteException
  {
    store.setTime(getTime());
    return store;
  }
}
