public static int getRemainingTimeout ( Long operationExpiryTimeInMs , Integer timeoutIntervalInMs ) throws StorageException { if ( operationExpiryTimeInMs != null ) { long remainingTime = operationExpiryTimeInMs - new Date ( ) . getTime ( ) ; if ( remainingTime > Integer . MAX_VALUE ) { return Integer . MAX_VALUE ; } else if ( remainingTime > 0 ) { return ( int ) remainingTime ; } else { TimeoutException timeoutException = new TimeoutException ( SR . MAXIMUM_EXECUTION_TIMEOUT_EXCEPTION ) ; StorageException translatedException = new StorageException ( StorageErrorCodeStrings . OPERATION_TIMED_OUT , SR . MAXIMUM_EXECUTION_TIMEOUT_EXCEPTION , Constants . HeaderConstants . HTTP_UNUSED_306 , null , timeoutException ) ; throw translatedException ; } } else if ( timeoutIntervalInMs != null ) { return timeoutIntervalInMs + Constants . DEFAULT_READ_TIMEOUT ; } else { return Constants . DEFAULT_READ_TIMEOUT ; } }
Returns a value representing the remaining time before the operation expires .