Q:

Error handling for SimpleDateFormat in Java

I am writing a program that takes a users input for hours and minutes in the format HH:MM, and returns a string of that input. For example, 13:56 would be "four minutes to two". 
I have created the code to do exactly that - take the input in that format and return a value as above. My issue is that I am not sure how to handle errors. I have a while loop that is meant to catch errors but it doesn't. I mainly want to ensure that if the user enters a character input (ee:rb or 12:bb etc.) or an invalid time (14:68 (I am going on a 12 hour clock)), that the program says "Error!" and makes the user try again. 
I have worked with exception handling, but have not done so for SimpleDateFormat and I can't figure out why the below does not work. 

A:

Try this:
public static void main(String[] args) {
    boolean safetyNet = false;
    Scanner in = new Scanner(System.in);
    Date d = new Date();
    SimpleDateFormat simpFormat = new SimpleDateFormat("hh:mm");

    while (!safetyNet) {
        System.out.println("Please enter the time in hours and minutes: ");
        String timeToString = in.next();
        try {
            d = simpFormat.parse(timeToString);
            safetyNet = true;
            String sHours = timeToString.substring(0, 2);
            String sMinutes = timeToString.substring(3);
            int hours = Integer.parseInt(sHours);
            int minutes = Integer.parseInt(sMinutes);
            String time=getTimeName(hours, minutes);
            if(time.isEmpty()){
                safetyNet = false;
            }else{
                System.out.printf("Time is: " + getTimeName(hours, minutes));
            }   
        } catch (ParseException e) {
            System.out.println("Error! Try again: ");
            // e.printStackTrace();
        }
    }
    in.close();
}

public static String getTimeName(int hours, int minutes) {
    String timeName = "";

    if (hours >= 1 && hours <= 12 && minutes >= 0 && minutes <= 59) {
        String hourBank[] = { "", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten",
                "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen",
                "Nineteen", "Twenty", "Twenty one", "Twenty two", "Twenty three", "Twenty four", "Twenty five",
                "Twenty six", "Twenty seven", "Twenty eight", "Twenty nine" };

        if (minutes == 0) {
            timeName = hourBank[hours] + " O'clock";
        }

        else if (minutes == 15) {
            timeName = "A quarter past " + hourBank[hours];
        }

        else if (minutes == 30) {
            timeName = "Half Past " + hourBank[hours];
        }

        else if (hours == 12 && minutes == 45) {
            timeName = "A quarter to " + hourBank[hours - 11];
        }

        else if (minutes == 45) {
            timeName = "A quarter to " + hourBank[hours + 1];
        }

        else if (minutes <= 29) {
            timeName = hourBank[minutes] + " minutes past " + hourBank[hours];
        }

        else if (hours == 12 && minutes >= 31 && minutes <= 59) {
            timeName = hourBank[60 - minutes] + " minutes to " + hourBank[hours - 11];
        }

        else if (minutes >= 31 && minutes <= 60) {
            timeName = hourBank[60 - minutes] + " minutes to " + hourBank[hours + 1];
        } else {
            timeName = "That's not the correct format!";
        }

    }else{
        System.out.println("minutes are between 0 and 60 and hours are between 0 and 12");
    }
    return timeName;
}

