Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-2804

LocalTimeValueType potential loss of precision

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 4.2.RC2
    • 5.0-M1
    • None
    • None

    Description

      I just ran into a problem (outside Cayenne) when conversion between "java.sql.Time" and "java.time.LocalTime" in either direction results in the loss of precision when based on the standard API (Time.valueOf(LocalTime) and Time.toLocalTime()). Everything is rounded to whole seconds.

      I think our LocalTimeValueType is also affected by this problem.

      Below is how I addressed it in Agrest. The use of "ZoneId.systemDefault()" in that implementation is somewhat questionable, but seems compatible with Time.toLocalTime() / Time.valueOf(LocalTime).

      Interestingly, no other conversions (like Timestamp to LocalDateTime) are affected. Their JDK versions are working properly.

      Attachments

        Activity

          People

            ntimofeev Nikita Timofeev
            andrus Andrus Adamchik
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: