michael-o commented on a change in pull request #147: Time values URL: https://github.com/apache/httpcomponents-core/pull/147#discussion_r321971306
########## File path: httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java ########## @@ -371,13 +347,43 @@ public int toSecondsIntBound() { return asBoundInt(toSeconds()); } + public Timeout toTimeout() { + return Timeout.of(duration, timeUnit); + } + @Override - public String toString() { - return String.format(Locale.ROOT, "%,d %s", duration, timeUnit); + public int compareTo(final TimeValue other) { + if (other != null) { + final TimeUnit targetTimeUnit = min(other.getTimeUnit()); + return Long.compare(convert(targetTimeUnit), other.convert(targetTimeUnit)); + } else { + return -Integer.MAX_VALUE; Review comment: This likely violates: The natural ordering for a class C is said to be consistent with equals if and only if e1.compareTo(e2) == 0 has the same boolean value as e1.equals(e2) for every e1 and e2 of class C. Note that null is not an instance of any class, and e.compareTo(null) should throw a NullPointerException even though e.equals(null) returns false. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For additional commands, e-mail: dev-h...@hc.apache.org