<PRE>
public class InoutDate extends Applet
{
    private String m_Month = "";
    private String m_Day = "";
    private String m_Year = "";

    // Parameter names.  To change a name of a parameter, you need only make
    // a single change.  Simply modify the value of the parameter string below.
    //--------------------------------------------------------------------------
    private final String PARAM_Month = "Month";
    private final String PARAM_Day = "Day";
    private final String PARAM_Year = "Year";
    private final String weekDayNames [] = {
        "Sunday", "Monday", "Tuesday", "Wednesday",
	"Thursday", "Friday", "Saturday"};
    
    private final String monthNames [] = {
        "January", "February", "March", "April",
        "May", "June", "July", "August", "September", "October",
        "November", "December" };
    private FontMetrics m_fm;
    PrivDate pd;
    PrivDate today;
    String dateInput;
    String dayOfWeek;
    String errLabel;
    PrivDate rightNow ;
    private TextField m_textField;
    private Label m_Label ;
    
    // InoutDate Class Constructor
    //--------------------------------------------------------------------------
    public InoutDate()
    {
    }

    // APPLET INFO SUPPORT:
    // The getAppletInfo() method returns a string describing the applet's
    // author, copyright date, or miscellaneous information.
    //--------------------------------------------------------------------------
    public String getAppletInfo()
    {
    	return //"Name: InoutDate\r\n" +
    	       //"Author: Patricia P. Watt\r\n" +
    	       //"Created with Microsoft Visual J++ Version 1.0"
    		  "  " ;
    }

    // PARAMETER SUPPORT
    //	The getParameterInfo() method returns an array of strings describing
    // the parameters understood by this applet.
    //
    // InoutDate Parameter Information:
    //  { "Name", "Type", "Description" },
    //--------------------------------------------------------------------------
    public String[][] getParameterInfo()
    {
    	String[][] info =
    	{
    		{ PARAM_Month, "String", "Parameter description" },
    		{ PARAM_Day, "String", "Parameter description" },
    		{ PARAM_Year, "String", "Parameter description" },
    	};
    	return info;		
    }

    // The init() method is called by the AWT when an applet is first loaded or
    // reloaded.  Override this method to perform whatever initialization your
    // applet needs, such as initializing data structures, loading images or
    // fonts, creating frame windows, setting the layout manager, or adding UI
    // components.
    //--------------------------------------------------------------------------
    public void init()
    {
    	// PARAMETER SUPPORT
    	//		The following code retrieves the value of each parameter
    	// specified with the <PARAM> tag and stores it in a member
    	// variable.
    	//----------------------------------------------------------------------
    	String param;

    	// Month: Parameter description
    	//----------------------------------------------------------------------
    	param = getParameter(PARAM_Month);
    	if (param != null)
    		m_Month = param;

    	// Day: Parameter description
    	//----------------------------------------------------------------------
    	param = getParameter(PARAM_Day);
    	if (param != null)
    		m_Day = param;

    	// Year: Parameter description
    	//----------------------------------------------------------------------
    	param = getParameter(PARAM_Year);
    	if (param != null)
    		m_Year = param;

        // If you use a ResourceWizard-generated "control creator" class to
        // arrange controls in your applet, you may want to call its
        // CreateControls() method from within this method. Remove the following
        // call to resize() before adding the call to CreateControls();
        // CreateControls() does its own resizing.
        //----------------------------------------------------------------------
    	//resize(320,240);
    	this.setBackground(Color.white);
    	Font f = getFont();
    	m_fm = getFontMetrics(f);
    	pd = new PrivDate(Integer.parseInt(m_Month), 
    				  Integer.parseInt(m_Day), 
    				  Integer.parseInt(m_Year));
    	Label firstLabel = new Label (" This applet will tell you ");
    	Label secondLabel = new Label (" the day of the week for any date between");
    	Label thirdLabel = new Label ("           January 1, 1900 and December 31, 2099            ");
    	add (firstLabel);
    	add (secondLabel);
    	add(thirdLabel);
    	m_Label = new Label (" Enter Date in mm/dd/yy format "); 
    	add(m_Label);
    	TextField m_textField = new TextField(10);
    	add(m_textField);

    }

    // Place additional applet clean up code here.  destroy() is called when
    // when you applet is terminating and being unloaded.
    //-------------------------------------------------------------------------
    public void destroy()
    {
    }

    // InoutDate Paint Handler
    //--------------------------------------------------------------------------
    public void paint(Graphics g)
    {
    	
    	int nY = m_fm.getHeight();
    	 Dimension dimWinSize = size();
    	 if ((dateInput != null) & (dayOfWeek != null) )
    	 {
    	 	int nWidth = m_fm.stringWidth(dateInput + dayOfWeek);
    		int nCentWide = (dimWinSize.width - nWidth) / 2;
    		int nCentHigh = (dimWinSize.height - nY)/2;
    		g.drawString(dateInput+dayOfWeek, nCentWide,nCentHigh + 3*nY);
    		nWidth = m_fm.stringWidth(errLabel);
    		nCentWide = (dimWinSize.width - nWidth) / 2;
    		g.drawString(errLabel, nCentWide, nCentHigh + 5*nY);
    	
    	 }
    }

    //		The start() method is called when the page containing the applet
    // first appears on the screen. The AppletWizard's initial implementation
    // of this method starts execution of the applet's thread.
    //--------------------------------------------------------------------------
    public void start()
    {

    }
    
    // The stop() method is called when the page containing the applet is
    // no longer on the screen. The AppletWizard's initial implementation of
    // this method stops execution of the applet's thread.
    //--------------------------------------------------------------------------
    public void stop()
    {
    }

    public boolean action (Event event, Object obj) 
    {
    	Object oTarget = event.target;
    	System.out.println(" Action:  " + obj);
    	if (oTarget instanceof TextField )
    	{
    		rightNow = new PrivDate( (String)obj );
    		dateInput = monthNames[rightNow.getMonth()-1] 
    				+ " " + Integer.toString(rightNow.getDate()) 
    				+ ", " + Integer.toString(rightNow.getYear()) 
    				+ " falls on " ;
    
      		dayOfWeek = weekDayNames[rightNow.getDayOfWeek()];
    		errLabel = rightNow.getErrLabel();
    		repaint();
    	}
    		return true;
    }

}

class PrivDate extends Object 
{
    private final static long MAGIC_NUMBER = 621049;
    private int m_iMonth;
    private int m_iDay;
    private int m_iYear;
    private long m_lNdays;
    private long m_lGmonth;
    private long m_lFyear;
    private int m_iDayOfWeek;
    private String errLabel;
    int daysInMonth [] = { 31,29,31,30,31,30,31,31,30,31,30,31 };

    PrivDate(int mm, int dd, int yy)
    {
    	if (validMonth(mm))
    	{
    		errLabel = ("                            ");
    	}
    	else
    	{
    		errLabel = (" Invalid Month ");
    	}

    	if (validYear (yy))
    	{
    		errLabel += ("                            ");
    	}
    	else
    	{
    		errLabel += ("Year is out of range");
    	}
    	
    	if (validDay(dd))
    	{
    		errLabel += ("                            ") ;
    	}
    	else
    	{
    		errLabel += ("Invalid Day of Month");
    	}
    	
    }

    PrivDate (String s)
    {
    	int firstSlash, secondSlash;
    	int mm,dd,yy;
    	System.out.println( "String Constructor" + s);

    	if ( (firstSlash = s.indexOf("/"))  != -1)
    	{
    		if ( (secondSlash = s.indexOf("/",firstSlash+1)) != -1)
    		{
    			if (s.indexOf("/",secondSlash + 1) == -1)
    			{
    				mm = Integer.parseInt(s.substring(0,firstSlash));
    				dd = Integer.parseInt(s.substring(firstSlash+1,secondSlash));
    				yy = Integer.parseInt(s.substring(secondSlash+1));
    				if (validMonth(mm))
    				{
    					errLabel = ("                            ");
    				}
    				else
    				{
    					errLabel = (" Invalid Month ");
    				}
    	
    				if (validYear (yy))
    				{
    					errLabel += ("                            ");
    				}
    				else
    				{
    					errLabel += ("Year is out of range");
    				}
    		
    				if (validDay(dd))
    				{
    					errLabel += ("                            ") ;
    				}
    				else
    				{
    					errLabel += ("Invalid Day of Month");
    				}

    			}
    			else
    			{
    			errLabel = new String ("Too Many Slashes");
    			m_iMonth = 1;
    			m_iDay = 1;
    			m_iYear = 1900;
    			}
    		}
    		else
    		{
    			errLabel = new String ("2d Slash not found after " + (firstSlash +1));
    			m_iMonth = 12;
    			m_iDay = 31;
    			m_iYear = 2099;
    		}
    	}
    	else
    	{
    		errLabel = new String ("1st Slash not found");
    		m_iMonth = 1;
    		m_iDay = 1;
    		m_iYear = 2000;
    	}
    }

    public long getNdays () 
    {

    	if (m_iMonth <= 2) 
    	{
    		m_lGmonth = m_iMonth + 13;
    		m_lFyear = m_iYear -1;
    	}
    	else 
    	{
    		m_lFyear = m_iYear;
    		m_lGmonth = m_iMonth + 1;
    	}

    	return  (long) (m_lNdays = (int)((1461 * m_lFyear) / 4) + (int)((153*m_lGmonth) / 5) + m_iDay);
    }

    public int getDayOfWeek()
    {
    	return  m_iDayOfWeek = (int) (getNdays() - MAGIC_NUMBER) % 7; 
    }

    public int getMonth()
    {
    	return m_iMonth;
    }

    public int getDate()
    {
    	return m_iDay;
    }

    public int getYear()
    {
    	return m_iYear;
    }

    public String getErrLabel()
    {
    	return errLabel;
    }
    private boolean validMonth( int mm)
    {
    	if (mm <= 12 && mm > 0 )
    	{
    		m_iMonth = mm;
    		return true;
    	}
    	else
    	{
    		m_iMonth = mm % 12 + 1;
    		return false;
    	}
    }
    private boolean validDay(int dd)
    {
    	switch (m_iMonth)
    	{
    		case 2:
    			if( (dd <= 28 && dd > 0) | (dd == 29 && m_iYear % 4 == 0))
    			{
    				m_iDay = dd;
    				return true;
    			}
    			else 
    			{
    				m_iDay = 28;
    				return false;
    			}
    		default:
    			if (dd <= daysInMonth[m_iMonth -1] && dd > 0)
    			{
    				m_iDay = dd;
    				return true;
    			}
    			else
    			{
    				m_iDay = dd % daysInMonth[m_iMonth - 1] + 1;
    				return false;
    			}
    		


    	}
    }

    private boolean validYear(int yy)
    {
    	m_iYear = yy;

    	if (m_iYear < 200) 
    	{
    		m_iYear += 1900;
    		return true;
    	}
    	else
    	{
    		if ((m_iYear < 1900) | (m_iYear > 2099))
    		{
    			m_iYear = (m_iYear % 200) + 1900;
    			return false;
    		}
    		return true;
    	}
    }
}
</PRE>

