// A class that implements the Date interface.
// Barry Cornelius, 19 June 2000
import java.util. StringTokenizer;
public class DateImplY implements Date
{
   private int iNumberOfDays;
   public DateImplY()
   {
      this(1970, 1, 1);
   }
   public DateImplY(final Date pDate)
   {
      final DateImplY tDateImplY = (DateImplY)pDate;
      iNumberOfDays = tDateImplY.iNumberOfDays;
   }
   public DateImplY(final int pYear, final int pMonth, final int pDay) 
   {
      iNumberOfDays = pYear*416 + pMonth*32 + pDay;
   }
   public DateImplY(final String pDateString)
   {
      try
      {
         final StringTokenizer tTokens =
                                new StringTokenizer(pDateString, "-");
         final String tYearString = tTokens.nextToken();
         final int tYear = Integer.parseInt(tYearString);
         final String tMonthString = tTokens.nextToken();
         final int tMonth = Integer.parseInt(tMonthString);
         final String tDayString = tTokens.nextToken();
         final int tDay = Integer.parseInt(tDayString);
         iNumberOfDays = tYear*416 + tMonth*32 + tDay;
      }
      catch(final Exception pException)
      {
         iNumberOfDays = 1970*416 + 1*32 + 1;
         throw new IllegalArgumentException();
      }
   } //BJCHEREFIRST
   public int getYear()
   {
      return iNumberOfDays/416;
   }
   public int getMonth()
   {
      return iNumberOfDays%416/32;
   }
   public int getDay()
   {
      return iNumberOfDays%32;
   }
   public void setYear(final int pYear)
   {
      iNumberOfDays = pYear*416 + iNumberOfDays%416;
   }
   public void setMonth(final int pMonth)
   {
      iNumberOfDays = iNumberOfDays/416*416 + pMonth*32 + iNumberOfDays%32;
   }
   public void setDay(final int pDay)
   {
      iNumberOfDays = iNumberOfDays/32*32 + pDay;
   }
   public boolean equals(final Object pObject)
   {
      if ( pObject==null || getClass()!=pObject.getClass() )
      {
         return false;
      }
      return iNumberOfDays==((DateImplY)pObject).iNumberOfDays;
   }
   public int hashCode()
   {
      return 0;
   }
   public String toString()
   {
      final int tYear = getYear();
      final int tMonth = getMonth();
      final int tDay = getDay();
      return tYear + "-" + tMonth/10 + tMonth%10 + "-" + tDay/10 + tDay%10;
   }
}
