public static boolean isTime ( String time ) { if ( isEmpty ( time ) ) return defaultEmptyOK ; String hour ; String minute ; String second ; int timeColon1 = time . indexOf ( ":" ) ; int timeColon2 = time . lastIndexOf ( ":" ) ; if ( timeColon1 <= 0 ) return false ; hour = time . substring ( 0 , timeColon1 ) ; if ( timeColon1 == timeColon2 ) { minute = time . substring ( timeColon1 + 1 ) ; second = "0" ; } else { minute = time . substring ( timeColon1 + 1 , timeColon2 ) ; second = time . substring ( timeColon2 + 1 ) ; } return isTime ( hour , minute , second ) ; }
isTime returns true if string argument time forms a valid time .