public static long fromHeaderValue(String serialized) {
        checkArgument(!serialized.isEmpty(), "empty timeout");
        checkArgument(serialized.length() <= 9, "bad timeout format");
        final long value = Long.parseLong(serialized.substring(0, serialized.length() - 1));
        final char unit = serialized.charAt(serialized.length() - 1);
        switch (unit) {
            case 'n':
                return TimeUnit.NANOSECONDS.toNanos(value);
            case 'u':
                return TimeUnit.MICROSECONDS.toNanos(value);
            case 'm':
                return TimeUnit.MILLISECONDS.toNanos(value);
            case 'S':
                return TimeUnit.SECONDS.toNanos(value);
            case 'M':
                return TimeUnit.MINUTES.toNanos(value);
            case 'H':
                return TimeUnit.HOURS.toNanos(value);
            default:
                throw new IllegalArgumentException(String.format("Invalid timeout unit: %s", unit));
        }
    }
public static long fromHeaderValue ( String serialized ) { checkArgument ( ! serialized . isEmpty ( ) , "empty timeout" ) ; checkArgument ( serialized . length ( ) <= 9 , "bad timeout format" ) ; final long value = Long . parseLong ( serialized . substring ( 0 , serialized . length ( ) - 1 ) ) ; final char unit = serialized . charAt ( serialized . length ( ) - 1 ) ; switch ( unit ) { case 'n' : return TimeUnit . NANOSECONDS . toNanos ( value ) ; case 'u' : return TimeUnit . MICROSECONDS . toNanos ( value ) ; case 'm' : return TimeUnit . MILLISECONDS . toNanos ( value ) ; case 'S' : return TimeUnit . SECONDS . toNanos ( value ) ; case 'M' : return TimeUnit . MINUTES . toNanos ( value ) ; case 'H' : return TimeUnit . HOURS . toNanos ( value ) ; default : throw new IllegalArgumentException ( String . format ( "Invalid timeout unit: %s" , unit ) ) ; } }
Parse the timeout from the {@link String}.