/** * returns a date that corresponds to the first time a request can be retried. * * @param retryAfter String in <a href="https://tools.ietf.org/html/rfc2616#section-14.37" * >Retry-After format</a> */ public Date apply(String retryAfter) { if (retryAfter == null) { return null; } if (retryAfter.matches("^[0-9]+$")) { long deltaMillis = SECONDS.toMillis(Long.parseLong(retryAfter)); return new Date(currentTimeMillis() + deltaMillis); } synchronized (rfc822Format) { try { return rfc822Format.parse(retryAfter); } catch (ParseException ignored) { return null; } } } }