### Question:
AmazonHttpClient { int parseClockSkewOffset(HttpResponse response, AmazonServiceException exception) { final Date deviceDate = new Date(); Date serverDate = null; String serverDateStr = null; final String responseDateHeader = response.getHeaders().get("Date"); try { if (responseDateHeader == null || responseDateHeader.isEmpty()) { serverDateStr = getServerDateFromException(exception.getMessage()); serverDate = DateUtils.parseCompressedISO8601Date(serverDateStr); } else { serverDateStr = responseDateHeader; serverDate = DateUtils.parseRFC822Date(serverDateStr); } } catch (final RuntimeException e) { log.warn("Unable to parse clock skew offset from response: " + serverDateStr, e); return 0; } final long diff = deviceDate.getTime() - serverDate.getTime(); return (int) (diff / TIME_MILLISEC); } AmazonHttpClient(ClientConfiguration config); @Deprecated  AmazonHttpClient(ClientConfiguration config,
            RequestMetricCollector requestMetricCollector);  AmazonHttpClient(ClientConfiguration config, HttpClient httpClient); @Deprecated  AmazonHttpClient(ClientConfiguration config, HttpClient httpClient,
            RequestMetricCollector requestMetricCollector); @Deprecated ResponseMetadata getResponseMetadataForRequest(AmazonWebServiceRequest request); Response<T> execute(Request<?> request,
            HttpResponseHandler<AmazonWebServiceResponse<T>> responseHandler,
            HttpResponseHandler<AmazonServiceException> errorResponseHandler,
            ExecutionContext executionContext); void shutdown(); RequestMetricCollector getRequestMetricCollector();  }### Answer:
@Test public void testClockskewOffset() { HttpResponse httpResponse = new HttpResponse.Builder().statusText("TestResponse") .header("Date", "Sat, 06 Nov 2004 08:49:37 GMT") .statusCode(400).build(); AmazonServiceException ase = new AmazonServiceException("ClockSkew"); int offset = client.parseClockSkewOffset(httpResponse, ase); assertTrue(offset > 315400000); }
@Test public void testClockskewOffsetWithDateInBodyOfException() { HttpResponse httpResponse = new HttpResponse.Builder().statusText("TestResponse") .statusCode(400).build(); AmazonServiceException ase = new AmazonServiceException("(20041106T084937Z - 15)"); int offset = client.parseClockSkewOffset(httpResponse, ase); assertTrue(offset > 315400000); }
@Test public void testClockskewOffsetWithBogusDateAsssumesOffsetIsZero() { HttpResponse httpResponse = new HttpResponse.Builder().statusText("TestResponse") .header("Date", "Sat, 064 Jann 20044 08:49:37 GMT") .statusCode(400).build(); AmazonServiceException ase = new AmazonServiceException("ClockSkew"); int offset = client.parseClockSkewOffset(httpResponse, ase); assertEquals(offset, 0); }