public static long parseTimeString ( String time ) { String trimmed = time . trim ( ) ; long result = 0 ; if ( trimmed . length ( ) > 0 ) { Matcher mat = SIMPLE . matcher ( trimmed ) ; if ( mat . matches ( ) ) { int days = ( mat . group ( SIM_DAY ) != null ) ? Integer . parseInt ( mat . group ( SIM_DAY ) ) : 0 ; int hours = ( mat . group ( SIM_HOU ) != null ) ? Integer . parseInt ( mat . group ( SIM_HOU ) ) : 0 ; int min = ( mat . group ( SIM_MIN ) != null ) ? Integer . parseInt ( mat . group ( SIM_MIN ) ) : 0 ; int sec = ( mat . group ( SIM_SEC ) != null ) ? Integer . parseInt ( mat . group ( SIM_SEC ) ) : 0 ; int ms = ( mat . group ( SIM_MS ) != null ) ? Integer . parseInt ( mat . group ( SIM_MS ) ) : 0 ; long r = days * DAY_MS + hours * HOU_MS + min * MIN_MS + sec * SEC_MS + ms ; if ( mat . group ( SIM_SGN ) != null && mat . group ( SIM_SGN ) . equals ( "-" ) ) { r = - r ; } result = r ; } else if ( "*" . equals ( trimmed ) || "+*" . equals ( trimmed ) ) { // positive infinity result = Long . MAX_VALUE ; } else if ( "-*" . equals ( trimmed ) ) { // negative infinity result = Long . MIN_VALUE ; } else { throw new RuntimeException ( "Error parsing time string: [ " + time + " ]" ) ; } } return result ; }
Parses the given time String and returns the corresponding time in milliseconds