<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">
I think that would be a great way to go ahead, providing generality while also showing applicable examples.</div>
<div id="appendonsend"></div>
<div><br>
<div style="font-family: Calibri; text-align: left; color: rgb(0, 0, 0); margin-left: 5pt; font-size: 10pt;">
Confidential – Oracle Internal</div>
</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> Pavel Rappo <pavel.rappo@gmail.com><br>
<b>Sent:</b> Tuesday, October 14, 2025 3:00 PM<br>
<b>To:</b> Chen Liang <chen.l.liang@oracle.com><br>
<b>Cc:</b> concurrency-discuss@openjdk.org <concurrency-discuss@openjdk.org><br>
<b>Subject:</b> [External] : Re: Clarification to TimeUnit.convert(Duration)</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">It's not really a specification, as it's @apiNote. IMO, referring to<br>
specific methods is good, it aids quick grasping of the idea. No<br>
matter what method Duration might have later, e.g. toMicros(), any<br>
sub-second conversion method can overflow. Maybe we can say that and<br>
add a few examples of the conversion methods that do?<br>
<br>
On Tue, Oct 14, 2025 at 10:44 PM Chen Liang <chen.l.liang@oracle.com> wrote:<br>
><br>
> Hi Pavel,<br>
><br>
> 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.<br>
><br>
> Chen<br>
> ________________________________<br>
> From: concurrency-discuss <concurrency-discuss-retn@openjdk.org> on behalf of Pavel Rappo <pavel.rappo@gmail.com><br>
> Sent: Monday, October 13, 2025 10:11 AM<br>
> To: concurrency-discuss@openjdk.org <concurrency-discuss@openjdk.org><br>
> Subject: Re: Clarification to TimeUnit.convert(Duration)<br>
><br>
> 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>