Avoid unnecessary use of Instant.toEpochMilli
Avoid unnecessary use of Instant.toEpochMilli by using Instant.compareTo to compare Instants direclty
This commit is contained in:
parent
15951d8094
commit
518eb410fe
|
@ -59,7 +59,7 @@ public class CookiePriorityComparator implements Comparator<Cookie> {
|
|||
final Instant d1 = c1.getCreationInstant();
|
||||
final Instant d2 = c2.getCreationInstant();
|
||||
if (d1 != null && d2 != null) {
|
||||
return (int) (d1.toEpochMilli() - d2.toEpochMilli());
|
||||
return d1.compareTo(d2);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -269,7 +269,7 @@ public final class BasicClientCookie implements SetCookie, Cloneable, Serializab
|
|||
public boolean isExpired(final Date date) {
|
||||
Args.notNull(date, "Date");
|
||||
return (cookieExpiryDate != null
|
||||
&& cookieExpiryDate.toEpochMilli() <= DateUtils.toInstant(date).toEpochMilli());
|
||||
&& cookieExpiryDate.compareTo(DateUtils.toInstant(date)) <= 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -282,7 +282,7 @@ public final class BasicClientCookie implements SetCookie, Cloneable, Serializab
|
|||
public boolean isExpired(final Instant instant) {
|
||||
Args.notNull(instant, "Instant");
|
||||
return (cookieExpiryDate != null
|
||||
&& cookieExpiryDate.toEpochMilli() <= instant.toEpochMilli());
|
||||
&& cookieExpiryDate.compareTo(instant) <= 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue