I'm trying to traverse a String value HH:MM:SS to determine if the colons are missing, if there are any non-numeric values, or if the values are out of range. Later in the method I also created a String array to create an object that is returned by the method. That part I've already go figure out. I need to error check the text entered which is passed to the method as a String. So what I did was create a variable newTime to hold the passed value and I plan on traversing the String till I find characters that aren't numbers. My idea is to traverse the String to find any non-numeric characters and throw an exception as you can see. It's not processing correctly when this method is called. The exception is always thrown and it looks like my for loop isn't processing properly. Any help is ap
String COLON = ":";
try{
for (int i = 0; i < newTime.length(); i++) {
if (newTime.charAt(i) != COLON.charAt(0)) {
JOptionPane.showMessageDialog(null, "Time format must be HH:MM:SS");
throw new InvalidTime("Time delimiter must be a \"" + COLON + "\"");
}
}
} //end try block
catch(InvalidTime ex) {
System.out.println("Exception: " + ex + " thrown");
} // end catch block
