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

LocalTime with(MILLI_OF_DAY/MICRO_OF_DAY) incorrect

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8u20
    • 8
    • core-libs
    • b11

        The implementation for LocalTime with(MILLI_OF_DAY, n) and LocalTime with(MICRO_OF_DAY, n) fails to match the specification.

        LocalTime base = LocalTime.of(12, 30, 40, 987654321);

        LocalTime result = base.with(MILLI_OF_DAY, 0);
        expected: 00:00:00.000000000
        was: 00:00:00.000654321

        LocalTime result = base.with(MICRO_OF_DAY, 0);
        expected: 00:00:00.000000000
        was: 00:00:00.000000321

        The spec is clear in both cases - "This completely replaces the time and is equivalent to using {@link #ofNanoOfDay(long)}", thus this is clearly a bug.

        The bug fix should be backported to JDK 8u.

              rriggs Roger Riggs
              scolebourne Stephen Colebourne
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: