/** * A very simple implementation of dates using Gregorian-style * calendars (with year, month, and day). * * @author Samuel A. Rebelsky * @version 1.2 of September 1998 */ public class SimpleDate { // +--------+-------------------------------------------------- // | Fields | // +--------+ /** The year. */ protected int year; /** The month. Use 1 for January, 2 for February, ... */ protected int month; /** The day in the month. */ protected int day; // +--------------+-------------------------------------------- // | Constructors | // +--------------+ /** * Build a new date with year, month, and day. The month should be * between 1 and 12 and the day between 1 and the number of days in * the month. */ public SimpleDate(int y, int m, int d) { this.year = y; this.month = m; this.day = d; } // SimpleDate(int,int,int) // +------------+---------------------------------------------- // | Extractors | // +------------+ /** * Get the year. */ public int getYear() { return this.year; } // getYear() /** * Get the month. */ public int getMonth() { return this.month; } // getMonth() /** * Get the day. */ public int getDay() { return this.day; } // getDay() /** * Convert to a string (American format: MM/DD/YYYY) */ public String toString() { return this.month + "/" + this.day + "/" + this.year; } // toString() } // class SimpleDate