So I'm writing a code that tests to see if an input is in the right time format of HH:MM:SS.sss, to check it properly I run four different inputs, three that should return false and one that should return True, but for some reason when I input the correct format I get an "Java.text.ParseExcetion data: "02:26:13.125"" and it returns false. what am i doing wrong or missing? here is my code
public static boolean checkTradeTimeFmt(String trade_time){
if (trade_time == null)
return false;
//set the format to use as a constructor argument
SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mm:ss.sss");
if (trade_time.trim().length() != dateFormat.toPattern().length())
return false;
dateFormat.setLenient(false);
try {
//parse the trade_time parameter
dateFormat.parse(trade_time.trim());
}
catch (ParseException pe) {
return false;
}
return true;
}