Re: RFR: 8351017: ChronoUnit.MONTHS.between() not giving correct result when date is in February

2025-03-06 Thread Stephen Colebourne
On Thu, 6 Mar 2025 23:36:29 GMT, Naoto Sato wrote: > Clarifying the explanation for `TemporalUnit.between()`. There is already an > example for the `HOURS` case where the minutes are not enough to make a full > hour. Explaining how smaller units contribute to determining the whole > number, al

Re: RFR: 8349189: Speed up DateTime parse & format via Class File API [v2]

2025-02-03 Thread Stephen Colebourne
On Mon, 3 Feb 2025 13:07:54 GMT, Shaojin Wen wrote: >> src/java.base/share/classes/java/time/temporal/TemporalAccessor.java line >> 327: >> >>> 325: * @return the year, from MIN_YEAR to MAX_YEAR >>> 326: */ >>> 327: default int getYear() { >> >> The whole point of `TemporalAccess

Re: RFR: 8349189: Speed up DateTime parse & format via Class File API

2025-02-03 Thread Stephen Colebourne
On Fri, 31 Jan 2025 10:29:53 GMT, Shaojin Wen wrote: > By using the Class File API to dynamically generate a CompositePrinterParser, > and defining DateTimePrinterParser[] printerParsers as a specific field, C2 > can do TypeProfile optimization. > > Since the CompositePrinterParser is generate

Re: Deprecate Double.MIN_VALUE?

2024-12-03 Thread Stephen Colebourne
On Tue, 3 Dec 2024 at 18:37, Louis Wasserman wrote: > To add some more data, from taking a sample, at least a third of usages in > Google's codebase were using it incorrectly in the way we've described. I just checked, and only a few days ago I made this error (in a test case, where it is less n

Re: RFR: 8339803: Acknowledge case insensitive unambiguous keywords in tzdata files [v2]

2024-09-16 Thread Stephen Colebourne
On Mon, 16 Sep 2024 19:30:56 GMT, Naoto Sato wrote: >> make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java line 308: >> >>> 306: if (off < tokens.length) { >>> 307: String dayRule = tokens[off++]; >>> 308: if (dayRule.regionMatches(true, 0

Re: RFR: 8339803: Acknowledge case insensitive unambiguous keywords in tzdata files [v2]

2024-09-16 Thread Stephen Colebourne
On Tue, 10 Sep 2024 22:42:37 GMT, Naoto Sato wrote: >> This is a follow on fix to >> [JDK-8339644](https://bugs.openjdk.org/browse/JDK-8339644). It turned out >> that TZ data files allow abbreviation of keywords, such as "ZO" for "Zone." >> Same fix, i.e, replacing `startsWith()` with `regionM

Re: RFR: 8337279: Optimize format instant [v7]

2024-08-31 Thread Stephen Colebourne
dd JavaTimeAccess SharedSecrets > - Merge remote-tracking branch 'upstream/master' into > optim_instant_fmt_202407 > - breaking out the printNano methods > - copyright > - Update > src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java > &

Re: Package.getPackage deprecation

2024-08-11 Thread Stephen Colebourne
On Sun, 11 Aug 2024 at 17:19, Alan Bateman wrote: > Package.getPackage is deprecated a long time, I don't think we've seen too > many complaints. Nowadays it's probably not too useful except to get to > package annotations (everything else in that API dates from JDK 1.2 and the > since removed

Package.getPackage deprecation

2024-08-11 Thread Stephen Colebourne
I make use of Package.getPackage in Joda-Convert but the method has now been deprecated. I'd like to update my code, but AFAICT the suggested alternative does not work. The Joda-Convert code allows a user to convert a Package object to a String, and back again. Reading the deprecation, I'm aware t

Re: RFR: 8337832: Optimize datetime toString

2024-08-11 Thread Stephen Colebourne
On Sat, 27 Jul 2024 13:45:11 GMT, Shaojin Wen wrote: > Similar to PR #20321, this improves performance by providing a method that > passes in a StringBuilder to avoid unnecessary object allocation. Change looks fine, but is it actually faster? - Marked as reviewed by scolebourne (

Re: RFR: 8337279: Optimize format instant [v4]

2024-08-11 Thread Stephen Colebourne
t incrementally with one additional > commit since the last revision: > > Update > src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java > > Co-authored-by: Stephen Colebourne A more productive direction might be to move `LocalDate.formatTo` and `Local

Re: RFR: 8337279: Optimize format instant [v3]

2024-08-11 Thread Stephen Colebourne
On Sun, 28 Jul 2024 15:52:03 GMT, Shaojin Wen wrote: >> By removing the redundant code logic in >> DateTimeFormatterBuilder$InstantPrinterParser#formatTo, the codeSize can be >> reduced and the performance can be improved. > > Shaojin Wen has updated the pull request incrementally with one addi

Re: RFR: 8337838: Remove unused methods from ChronoLocalDateImpl

2024-08-07 Thread Stephen Colebourne
On Fri, 19 Jul 2024 09:52:50 GMT, Andrey Turbanov wrote: > A few methods in `java.time.chrono.ChronoLocalDateImpl` are unused and could > be removed: > 1. plusWeeks(long) > 2. minusYears(long) > 3. minusMonths(long) > 4. minusWeeks(long) > 5. minusDays(long) > > Tested `test/jdk/java/time` on L

Re: RFR: 8337279: Optimize format instant [v2]

2024-07-28 Thread Stephen Colebourne
On Fri, 26 Jul 2024 15:32:18 GMT, Shaojin Wen wrote: >> src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java >> line 3818: >> >>> 3816: } >>> 3817: // add fraction >>> 3818: if (fractionalDigits > 0) { >> >> This breaks the logic. `frac

Re: RFR: 8337279: Optimize format instant [v2]

2024-07-28 Thread Stephen Colebourne
On Fri, 26 Jul 2024 15:44:59 GMT, Shaojin Wen wrote: >> By removing the redundant code logic in >> DateTimeFormatterBuilder$InstantPrinterParser#formatTo, the codeSize can be >> reduced and the performance can be improved. > > Shaojin Wen has updated the pull request incrementally with one addi

Re: RFR: 8337279: Optimize format instant

2024-07-26 Thread Stephen Colebourne
On Fri, 26 Jul 2024 14:20:07 GMT, Shaojin Wen wrote: > By removing the redundant code logic in > DateTimeFormatterBuilder$InstantPrinterParser#formatTo, the codeSize can be > reduced and the performance can be improved. src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java

Re: RFR: 8337168: Optimize LocalDateTime.toString [v4]

2024-07-26 Thread Stephen Colebourne
On Thu, 25 Jul 2024 23:05:46 GMT, Shaojin Wen wrote: >> The current LocalDateTime.toString implementation concatenates the toString >> results of date and time, which can be passed to StringBuilder to reduce >> additional object allocation and improve performance. > > Shaojin Wen has updated th

Re: java.time lacks start and end aware period data types

2024-06-19 Thread Stephen Colebourne
There are a variety of ways that a range of the timeline can be defined. And some would argue that Java should have a general purpose Range class to cover all Comparable classes rather than a few specific ones for Java time. Ultimately, Java time chose to avoid the issues by not addressing the des

Re: Instant.now(Clock) and InstantSource

2024-06-04 Thread Stephen Colebourne
On Mon, 3 Jun 2024 at 22:25, Kurt Alfred Kluever wrote: > It feels a bit strange that you can't pass an `InstantSource` to > `Instant.now(...)`, but you _can_ pass a `Clock` (which of course has a > "useless" `ZoneId` when creating an `Instant`). Therefore, I'd like to > propose one of the foll

Re: In support of Instant.minus(Instant)

2024-05-16 Thread Stephen Colebourne
Durations is an affine space >> >>> <https://en.wikipedia.org/wiki/Affine_space#Definition>, with >> >>> instants the points and durations the vectors. (An affine space is >> >>> a vector space without a distinguished origin, which of cours

Re: In support of Instant.minus(Instant)

2024-05-02 Thread Stephen Colebourne
On Thu, 2 May 2024 at 15:58, Kurt Alfred Kluever wrote: > instant − instant = duration // what we're discussing > instant + duration = instant // satisfied by instant.plus(duration) > instant - duration = instant // satisfied by instant.minus(duration) > duration + duration = duration // satisfied

Re: RFR: 8331202: Support for Duration until another Instant [v2]

2024-04-29 Thread Stephen Colebourne
On Mon, 29 Apr 2024 21:32:16 GMT, Naoto Sato wrote: >> A new method on Instant to return the duration `until` another Instant is >> suggested per the following discussion thread: >> >> https://mail.openjdk.org/pipermail/core-libs-dev/2024-April/122131.html >> >> A CSR has also been drafted. >

Re: In support of Instant.minus(Instant)

2024-04-25 Thread Stephen Colebourne
java.time.* already has the `until(ChronoLocalDate)` method on LocalDate. It would be reasonable to add a similar method to various other classes. This potentially gives you Duration dur = start.until(end) I'm wary of adding the opposite (given until() is already there). I'm particularly wary of

Re: RFR: 8313231: Redundant if statement in ZoneInfoFile

2023-07-31 Thread Stephen Colebourne
On Thu, 27 Jul 2023 06:46:46 GMT, John Jiang wrote: > if (i < savingsInstantTransitions.length) { > // javazic writes the last GMT offset into index 0! > if (i < savingsInstantTransitions.length) { > offsets[0] = standardOffsets[standardOffsets.length - 1] * 1000; > nOffse

Re: RFR: 8313231: Redundant if statement in ZoneInfoFile

2023-07-31 Thread Stephen Colebourne
On Thu, 27 Jul 2023 11:01:23 GMT, Pavel Rappo wrote: >> if (i < savingsInstantTransitions.length) { >> // javazic writes the last GMT offset into index 0! >> if (i < savingsInstantTransitions.length) { >> offsets[0] = standardOffsets[standardOffsets.length - 1] * 1000; >>

Re: RFR: 8310033: Clarify return value of Java Time compareTo methods [v9]

2023-07-21 Thread Stephen Colebourne
On Fri, 21 Jul 2023 15:59:42 GMT, Roger Riggs wrote: >> In java.time packages, clarify timeline order javadoc to mention "before" >> and "after" in the value of the `compareTo` method return values. >> Add javadoc @see tags to isBefore and isAfter methods >> >> Replace use of "negative" and po

Re: RFR: 8310033: Clarify return value of Java Time compareTo methods [v7]

2023-07-20 Thread Stephen Colebourne
On Tue, 11 Jul 2023 17:54:23 GMT, Roger Riggs wrote: >> In java.time packages, clarify timeline order javadoc to mention "before" >> and "after" in the value of the `compareTo` method return values. >> Add javadoc @see tags to isBefore and isAfter methods >> >> Replace use of "negative" and po

Re: RFR: 8310033: Clarify return value of Java Time compareTo methods [v2]

2023-06-18 Thread Stephen Colebourne
On Fri, 16 Jun 2023 22:12:43 GMT, Roger Riggs wrote: >> In java.time packages, clarify timeline order javadoc to mention "before" >> and "after" in the value of the `compareTo` method return values. >> Add javadoc @see tags to isBefore and isAfter methods >> >> Replace use of "negative" and po

Re: RFR: 8307466: java.time.Instant calculation bug in until and between methods

2023-05-06 Thread Stephen Colebourne
On Fri, 5 May 2023 21:28:25 GMT, Roger Riggs wrote: > The implementation of java.time.Instant.until(I2, ChronoUnit) in some cases > did not correctly borrow or carry from the nanos to the seconds when > computing using ChronoUnit.MILLIS or ChronoUnit.MICROS. > The errant computation was introdu

Re: Time difference calculation bug

2023-05-03 Thread Stephen Colebourne
This looks like a bug from the description below, although it is surprising that it isn't caught by tests. Stephen On Wed, 3 May 2023, 21:47 SHARPE, Stuart (Commercial & Institutional CDIO), wrote: > Hi Roger, > > Thanks for the reply. > > I must admit I am struggling to understand your explanat

Re: RFR: 8301552: Use AtomicReferenceArray for caching instead of CHM in ZoneOffset [v4]

2023-02-02 Thread Stephen Colebourne
On Wed, 1 Feb 2023 20:19:20 GMT, cheenar wrote: >> test/jdk/java/time/tck/java/time/zone/TCKFixedZoneRules.java line 141: >> >>> 139: @Test(dataProvider="rules") >>> 140: public void test_isValidOffset_LDT_ZO(ZoneRules test, ZoneOffset >>> expectedOffset) { >>> 141: if (expected