regarding the code: the first parseInt catches the exception, the second doesn't ?
this line is wrong: !time.substring(9, 11).equals("AM") & !time.substring(9, 11).equals("PM") & should be && the boolean and operator