I've had some serious troubles getting this class to compile. I'm just looking for a little help with this.
import java.util.*; //Date import java.text.*; //.DateFormat, .SimpleDateFormat public class Time { public int hours = 0; public int minutes = 0; //no arg constructor public Time() { } //Default Constructor public Time(int inHours, int inMinutes) { this.hours = inHours; this.minutes = inMinutes; } //Hours accessor public int getHours() { return hours; } //Minutes accessor public int getMinutes() { return minutes; } public String fromString(String stringTime) { //overrides .Object method toString() to use this classes toString() method //to split 24-hour time to hours and minutes //DEAD CODE--Time newTime = new Time(hours, minutes).toString(stringTime); //Convert stringTime to minutes then take the difference between that and //total minustes in a day (1440) //DEAD CODE--int timeDiff = 1440 - stringTime.toMinutes(); //need to figure out how to determine if newTime is out of range if (!outOfRange()) { return stringTime; } else { System.out.print("The time is out of range, program terminating"); } } //end fromString method @Override public String toString() { //Converts a time object to 24hr format string //Display hours and minutes in 2 spaces each //Display leading zeros for minute field //use : as separator SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm"); try { Date parseTime = timeFormat.parse(new Time(hours, minutes)); //This isn't correct--> "parse(timeFormat)" //can't determine what is parsed here. return timeFormat.format(parseTime); } catch (ParseException e) { e.printStackTrace(); } } public String toAMPMString() { //public instance method //Display hours and minutes in 2 spaces each //Display leading zeros for minute field //use : as separator //AM/PM follows the hours and minutes String THour = ""; int temp = 0; DecimalFormat twoDigits = new DecimalFormat("00"); // checking for noon and midnight if (hours == 0 || hours == 12) { temp = 12; } // cast hour into correct number of hours since 0000/1200 else { temp = hours % 12; } // determine whether it is AM or PM by hour if (hours < 12) { THour = "AM"; } else { THour = "PM"; } return temp + ":" + twoDigits.format(hours) + ":" + twoDigits.format(minutes) + " " + THour; } @Override public int compareTo(int arrival, int departure) { //String isBefore = arrival.compareTo(departure); //Arrival is before departure if (arrival.toMinutes() < departure.toMinutes()) return -1; //Times are equal else if (arrival.toMinutes() == departure.toMinutes()) return 0; //Arrival is after departure else return 1; } protected int toMinutes() { //returns time in minutes since midnight SimpleDateFormat dateFormat = new SimpleDateFormat("HH"); Date date = new Date(Time(hours, minutes)); int hour = Integer.parseInt(dateFormat.format(date)); SimpleDateFormat dateFormat = new SimpleDateFormat("mm"); Date date = new Date(Time(hours, minutes)); int minute = Integer.parseInt(dateFormat.format(date)); //Minutes from midnight int minFromMidnight = (hours* 60) + minute; } public static boolean outOfRange() { //return true if hours and minutes are not within proper range of values //return false otherwise if ((hours > 23 || hours < 0) && (minutes > 59 || minutes < 0)) { return true; } else { return false; } } } //end of class