<div dir="auto"><p dir="ltr">How does it not model an interval?</p><p dir="ltr">Here is the official documentation.</p><p dir="ltr"><i><b><u>Obtains a Period consisting of the number of years, months, and days between two dates.</u></b></i></p>
<p dir="ltr"><a href="https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/time/Period.html#between(java.time.LocalDate,java.time.LocalDate)" target="_blank" rel="noreferrer">https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/time/Period.html#between(java.time.LocalDate,java.time.LocalDate)</a></p><p dir="ltr">And here is the dictionary definition.</p><p dir="ltr"><b><i><u>a space of time between events or states</u></i></b></p>
<p dir="ltr"><a href="https://www.merriam-webster.com/dictionary/interval" target="_blank" rel="noreferrer">https://www.merriam-webster.com/dictionary/interval</a></p></div>
<br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 18, 2025, 7:30 AM Pavel Rappo <<a href="mailto:pavel.rappo@gmail.com" target="_blank" rel="noreferrer">pavel.rappo@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello, I have two questions on java.time API.<br>
<br>
The first one is about documentation for java.time.Period. When I get<br>
back to the API after a long period (no pun intended) of not using it,<br>
it takes me a while to recall that Period does __NOT__ model an<br>
interval between two specific points in time, such as vacation dates.<br>
And the signature of the Period.between(LocalDate, LocalDate) method<br>
makes it even harder.<br>
<br>
I'm not sure what it is. Is it because I'm a non-native English<br>
speaker or it's some idiosyncrasy? Anyway, if it's not just me, then<br>
my question is: would it make sense to provide a few short and punchy<br>
notes to the reader to quickly rectify this misconception that might<br>
be forming in their head while they are reading the documentation?<br>
Sometimes it's helpful to say what something isn't in addition to<br>
saying what something is.<br>
<br>
<br>
The second question is about DateTimeFormatter. I recently had to<br>
parse a date that resembles output of asctime: Sat Jul 16 02:03:55<br>
+0000 1994. It's fine and dandy until you parse a date in September.<br>
That time format expects "Sep", while the formatter expects "Sept".<br>
<br>
Now, I'm aware that it's a known issue [^1]. Still, I wonder if we can<br>
do anything better than suggest using a specific locale, which is not<br>
bulletproof, or going to the DateTimeFormatterBuilder route.<br>
<br>
Thanks,<br>
-Pavel<br>
<br>
[^1]: See <a href="https://bugs.openjdk.org/browse/JDK-8256837" rel="noreferrer noreferrer noreferrer" target="_blank">https://bugs.openjdk.org/browse/JDK-8256837</a> and its numerous<br>
duplicates.<br>
</blockquote></div>