Skip to content

Commit 6075ac6

Browse files
committed
Merge pull request AsyncHttpClient#133 from slandelle/master
Minor changes to AsyncHttpProviderUtils.convertExpireField
2 parents c855412 + 1cf8d00 commit 6075ac6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

api/src/main/java/com/ning/http/util/AsyncHttpProviderUtils.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,12 +557,14 @@ public static Cookie parseCookie(String value) {
557557
return new Cookie(domain, cookieName, cookieValue, path, maxAge, secure);
558558
}
559559

560-
private static int convertExpireField(String timestring) throws Exception {
560+
public static int convertExpireField(String timestring) throws Exception {
561561
Exception exception = null;
562+
String trimmedTimeString = removeQuote(timestring.trim());
563+
long now = System.currentTimeMillis();
562564
for (SimpleDateFormat sdf : simpleDateFormat.get()) {
563565
try {
564-
long expire = sdf.parse(removeQuote(timestring.trim())).getTime();
565-
return (int) ((expire - System.currentTimeMillis()) / 1000);
566+
long expire = sdf.parse(trimmedTimeString).getTime();
567+
return (int) ((expire - now) / 1000);
566568
} catch (ParseException e) {
567569
exception = e;
568570
} catch (NumberFormatException e) {

0 commit comments

Comments
 (0)