I've been comparing some fields and want to confirm my suspicion that although LocalDateTime fields might 'look' like the same values as converted timestamps, that they really don't hold the same values?
I'm writing a record using:
...
LocalDateTime ts = LocalDateTime.now();
pStmt.setTimestamp (19,Timestamp.valueOf(ts));
pStmt.setTimestamp (20,Timestamp.valueOf(ts));
a.createdt = ts;
a.lastupdt = ts;
and later I am reading that same DB record into another instance using:
...
b.createdt = rs.getTimestamp("createdt").toLocalDateTime();
b.lastupdt = rs.getTimestamp("lastupdt").toLocalDateTime();
When I check if a.createdt == b.createdt
I get false
.
When I print the values as strings they look identical: "2016-03-21T23:40:38.700"
.
Am I correct that the actual values held in memory for comparison are somehow different? e.g. the database probably holds more or fewer nanoseconds? Or that the conversion to timestamp and back does some truncation?
TIA