Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
4.2.RC2
-
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).
- https://github.com/agrestio/agrest/blob/master/agrest-engine/src/main/java/io/agrest/converter/jsonvalue/SqlTimeConverter.java
- https://github.com/agrestio/agrest/blob/master/agrest-engine/src/main/java/io/agrest/converter/valuestring/SqlTimeConverter.java
Interestingly, no other conversions (like Timestamp to LocalDateTime) are affected. Their JDK versions are working properly.