home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wsgatsam.zip / CalendarServiceBean.java < prev    next >
Text File  |  2003-02-24  |  2KB  |  78 lines

  1. /**
  2.  * %wsgw_sample_start%
  3.  * Licensed Materials - Property of IBM  
  4.  *    
  5.  * (c) Copyright IBM Corp. 2001, 2002 All Rights Reserved.  
  6.  *    
  7.  * US Government Users Restricted Rights - Use, duplication or   
  8.  * disclosure restricted by GSA ADP Schedule Contract with   
  9.  * IBM Corp.  
  10.  * %wsgw_sample_end%
  11.  */
  12.  
  13. package services.calendar.ejb;
  14.  
  15.  
  16. import java.rmi.RemoteException;
  17. import java.util.Properties;
  18. import java.util.Calendar;
  19. import java.util.GregorianCalendar;
  20. import javax.ejb.*;
  21.  
  22. public class CalendarServiceBean implements SessionBean
  23. {
  24.   private javax.ejb.SessionContext mySessionCtx = null;
  25.   
  26.   public void ejbActivate()
  27.     throws java.rmi.RemoteException
  28.   {}
  29.  
  30.   public void ejbCreate()
  31.     throws javax.ejb.CreateException, java.rmi.RemoteException
  32.   {}
  33.  
  34.   public void ejbPassivate()
  35.     throws java.rmi.RemoteException
  36.   {}
  37.   
  38.   public void ejbRemove()
  39.     throws java.rmi.RemoteException
  40.   {}
  41.   
  42.   public javax.ejb.SessionContext getSessionContext()
  43.   {
  44.     return mySessionCtx;
  45.   }
  46.   
  47.   public void setSessionContext(javax.ejb.SessionContext ctx)
  48.     throws java.rmi.RemoteException
  49.   {
  50.     mySessionCtx = ctx;
  51.   }
  52.  
  53.   public String dayOfTheWeek(int month, int date, int year)
  54.     throws java.rmi.RemoteException
  55.   {
  56.     GregorianCalendar calendar = new GregorianCalendar(year, month-1, date);
  57.     switch (calendar.get(Calendar.DAY_OF_WEEK))
  58.     {
  59.     case Calendar.SUNDAY:
  60.       return "Sunday";
  61.     case Calendar.MONDAY:
  62.       return "Monday";
  63.     case Calendar.TUESDAY:
  64.       return "Tuesday";
  65.     case Calendar.WEDNESDAY:
  66.       return "Wednesday";
  67.     case Calendar.THURSDAY:
  68.       return "Thursday";
  69.     case Calendar.FRIDAY:
  70.       return "Friday";
  71.     case Calendar.SATURDAY:
  72.       return "Saturday";
  73.     default:
  74.       return "Unknown";
  75.     }
  76.   }
  77. }
  78.