/** * Extended time/date information, including not just the day, but also the * time of day. (Alternately, including not just the time, but the day on * which that time falls.) * * @author Samuel A. Rebelsky * @version 1.0 of January 1999 */ public class SimpleTime extends SimpleDate { // +--------+--------------------------------------------------- // | Fields | // +--------+ /** The hour of the day. */ public int hour; /** The minute of the day. */ public int minute; // +--------------+--------------------------------------------- // | Constructors | // +--------------+ /** * Create a new time, specifying all the components. */ public SimpleTime(int year, int month, int day, int hour, int minute) { // Set up the day without the time super(year,month,day); // Fill in the remaining information this.hour = hour; this.minute = minute; } // SimpleTime(int,int,int,int,int) /** * Create a new time, specifying only the day. Uses 0:00 as the hour and * minute. */ public SimpleTime(int year, int month, int day) { // Set up the day without the time super(year,month,day); // Fill in the remaining information this.hour = 0; this.minute = 0; } // SimpleTime(int,int,int) // +------------+----------------------------------------------- // | Extractors | // +------------+ /** * Get the hour. */ public int getHour() { return this.hour; } // getHour() /** * Get the minute. */ public int getMinute() { return this.minute; } // getMinute() /** * Convert to a string. */ public String toString() { if (this.minute < 10) { return this.hour + ":0" + this.minute + "," + super.toString(); } // if the minute is a single digit else { return this.hour + ":" + this.minute + "," + super.toString(); } // if the minute is multiple digits } // toString() } // class SimpleTime