Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8146218

Add LocalDate.datesUntil method producing Stream<LocalDate>

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b105

      Description

      The following methods could be added to java.time.LocalDate:

      // Return the Stream of all dates starting from this (inclusive) until the supplied one (exclusive)
      Stream<LocalDate> datesUntil(LocalDate endExclusive);

      // Return the Stream of dates starting from this (inclusive) until the supplied one (exclusive) with given step.
      Stream<LocalDate> datesUntil(LocalDate endExclusive, Period step);

      The proposal is discussed here:
      http://mail.openjdk.java.net/pipermail/core-libs-dev/2015-December/037844.html

        Activity

        tvaleev Tagir Valeev created issue -
        Hide
        scolebourne Stephen Colebourne added a comment -
        The common case of adding a small number of days will perform relatively poorly unless JDK-8068803 is implemented. It may even be possible to do better in this special case.

        The period step case is interesting when dealing with months and years. To get an accurate result, the period must be multiplied by the loop index each time around the loop.

        Consider datesUntil() with a period of 1 month starting from Jan 31. The naive implementation would add the period each time, but this results in Feb 28, Mar 28, Apr 28 and so on. The correct implementation adds 1 month to the start, then adds 2 months to the start, then adds 3 months to the start, yielding Feb 28, Mar 31, Apr 30 and so on.

        Given the complications and performance implications, the implementation should probably have two paths, one for period with months/years and one for periods of just days.
        Show
        scolebourne Stephen Colebourne added a comment - The common case of adding a small number of days will perform relatively poorly unless JDK-8068803 is implemented. It may even be possible to do better in this special case. The period step case is interesting when dealing with months and years. To get an accurate result, the period must be multiplied by the loop index each time around the loop. Consider datesUntil() with a period of 1 month starting from Jan 31. The naive implementation would add the period each time, but this results in Feb 28, Mar 28, Apr 28 and so on. The correct implementation adds 1 month to the start, then adds 2 months to the start, then adds 3 months to the start, yielding Feb 28, Mar 31, Apr 30 and so on. Given the complications and performance implications, the implementation should probably have two paths, one for period with months/years and one for periods of just days.
        Show
        tvaleev Tagir Valeev added a comment - Webrev: http://cr.openjdk.java.net/~tvaleev/webrev/8146218/r3/
        hgupdate HG Updates made changes -
        Field Original Value New Value
        Status New [ 10000 ] Open [ 1 ]
        Hide
        hgupdate HG Updates added a comment -
        URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/737770475252
        User: rriggs
        Date: 2016-02-01 15:11:17 +0000
        Show
        hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/737770475252 User: rriggs Date: 2016-02-01 15:11:17 +0000
        hgupdate HG Updates made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolved In Build team [ 17324 ]
        Fix Version/s 9 [ 14949 ]
        Resolution Fixed [ 1 ]
        Hide
        hgupdate HG Updates added a comment -
        URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/737770475252
        User: lana
        Date: 2016-02-10 21:55:24 +0000
        Show
        hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/737770475252 User: lana Date: 2016-02-10 21:55:24 +0000
        hgupdate HG Updates made changes -
        Resolved In Build team [ 17324 ] master [ 18256 ]
        hgupdate HG Updates made changes -
        Resolved In Build master [ 18256 ] b105 [ 17826 ]
        iris Iris Clark made changes -
        Labels jsr379-annex2-tbd
        iris Iris Clark made changes -
        Labels jsr379-annex2-tbd jsr379-annex1

          People

          • Assignee:
            tvaleev Tagir Valeev
            Reporter:
            tvaleev Tagir Valeev
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: