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

Clarify that Time.toLocalTime treats the nanos as 0

    Details

    • Subcomponent:
    • Resolved In Build:
      b08

      Description

      LocalTime has a nano-of-second value with Time does not. So if you ran the following

         @Test
          public void test14() {
              LocalTime lt = LocalTime.now();
              //LocalTime lt = LocalTime.of(8, 30, 59);
              Time t = Time.valueOf(lt);
              assertTrue(lt.equals(t.toLocalTime()),
                      "Error LocalTime values are not equal");
          }

      The assertion would fail.

      if you use the LocalTime.of() method (which is what Time.toLocalTime() calls), the test will pass. The javadoc for LocalTime.of indicates that the nanos is set to zero.

        Attachments

          Activity

            People

            • Assignee:
              lancea Lance Andersen
              Reporter:
              lancea Lance Andersen
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: