question: private static double parseTime ( String s ) throws NumberFormatException { if ( s . length ( ) > 4 ) throw new NumberFormatException ( "Could not parse time: \"" + s + "\"!" ) ; double result = 0 ; char [ ] c = s . toCharArray ( ) ; char [ ] x = new char [ ] { '0' , '0' , '0' , '0' } ; for ( int i = 0 ; i < c . length ; i ++ ) x [ i + 4 - c . length ] = c [ i ] ; try { int hours = Integer . parseInt ( "" + x [ 0 ] + x [ 1 ] ) ; int minutes = Integer . parseInt ( "" + x [ 2 ] + x [ 3 ] ) ; result = hours * 3600 + minutes * 60 ; } catch ( NumberFormatException e ) { throw new NumberFormatException ( "Could not parse time: \"" + s + "\"!" ) ; } if ( result < ( 3 * 3600 ) ) result += ( 24 * 3600 ) ; return result ; }
target:  Parses the 4-character time representation hhmm, padding with leading zeroes