<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Hi Pavel,</div>
<div style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
I don't think specifying the enum constants is particularly meaningful - maybe future constants also have overflowing operations. Wording like "conversion methods on Duration" instead of just toNanos/toMillis would be more helpful though.</div>
<div style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Chen</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> concurrency-discuss <concurrency-discuss-retn@openjdk.org> on behalf of Pavel Rappo <pavel.rappo@gmail.com><br>
<b>Sent:</b> Monday, October 13, 2025 10:11 AM<br>
<b>To:</b> concurrency-discuss@openjdk.org <concurrency-discuss@openjdk.org><br>
<b>Subject:</b> Re: Clarification to TimeUnit.convert(Duration)</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">ping<br>
<br>
On Fri, Oct 3, 2025 at 9:54 PM Pavel Rappo <pavel.rappo@gmail.com> wrote:<br>
><br>
> TimeUnit.covert(Duration)'s receiver is an enum constant. Different<br>
> constants result in different converstions. So, it's a bit vague to<br>
> contrast "this method" to a specific conversion (in this case,<br>
> nanoseconds). Would this small clarification benefit the reader? If<br>
> so, I could create a PR.<br>
><br>
> diff --git a/src/java.base/share/classes/java/util/concurrent/TimeUnit.java<br>
> b/src/java.base/share/classes/java/util/concurrent/TimeUnit.java<br>
> index d116fb9b22b..6135461cf48 100644<br>
> --- a/src/java.base/share/classes/java/util/concurrent/TimeUnit.java<br>
> +++ b/src/java.base/share/classes/java/util/concurrent/TimeUnit.java<br>
> @@ -203,8 +203,11 @@ public long convert(long sourceDuration, TimeUnit<br>
> sourceUnit) {<br>
> * is equivalent to {@code n} (in the absence of overflow).<br>
> *<br>
> * @apiNote<br>
> - * This method differs from {@link Duration#toNanos()} in that it<br>
> - * does not throw {@link ArithmeticException} on numeric overflow.<br>
> + * {@link #NANOSECONDS}{@code .convert(Duration)} and<br>
> + * {@link #MILLISECONDS}{@code .convert(Duration)} differ from<br>
> + * {@link Duration#toNanos()} and {@link Duration#toMillis()} respectively<br>
> + * in that they do not throw {@link ArithmeticException} on numeric<br>
> + * overflow.<br>
> *<br>
> * @param duration the time duration<br>
> * @return the converted duration in this unit,<br>
</div>
</span></font></div>
</body>
</html>