michael-o commented on a change in pull request #147: Time values URL: https://github.com/apache/httpcomponents-core/pull/147#discussion_r321975546
########## 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; + } } - public Timeout toTimeout() { - return Timeout.of(duration, timeUnit); + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof TimeValue) { + final TimeValue that = (TimeValue) obj; + return this.duration == that.duration && LangUtils.equals(this.timeUnit, that.timeUnit); + } + return false; + } + + @Override + public int hashCode() { + int hash = LangUtils.HASH_SEED; + hash = LangUtils.hashCode(hash, duration); + hash = LangUtils.hashCode(hash, timeUnit); + return hash; + } + + @Override + public String toString() { + return String.format(Locale.ROOT, "%,d %s", duration, timeUnit); Review comment: It is, but I highly doubt that `ROOT` is much different than `en_US`. Therefore, output should be in neutral formatting. ---------------------------------------------------------------- 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