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

Duration returns truncated values as floats, which is confusing

    XMLWordPrintable

    Details

      Description

      I had a bug in my sample app that turned out to be due to my assumption, based on the return type, that Duration.toSeconds() would return a value like 4.1, i.e. with a fractional part. Turns out that this is not the case: Duration has a number of methods which return a truncated integer value as a float. This is not the end of the world, but you could expect new users to JavaFX to trip over this with some regularity. Why not just return an integer?

      Come to think of it, the name itself is part of the problem. I would expect dur.minutes() or dur.getMinutes() to return the integer number of minutes, but dur.toMinutes() sounds more like a conversion than an accessor, so I would expect to get a different representation of the duration rather than a different animal altogether.

      I'm putting this down as low priority, but obviously the time to fix this, if it should be fixed at all, is before 1.0 ships.

        Attachments

          Activity

            People

            Assignee:
            kcr Kevin Rushforth
            Reporter:
            nsterlinsunw Nicholas Sterling (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: