Paul Clapham wrote:You seem to be doing string-fiddling to convert between java.sql.Timestamp and java.time.Instant. There's no need to do that: Timestamp has a static method Timestamp.from(Instant) which converts an Instant object to a Timestamp object, and an instance method toInstant() which returns an Instant object.
Knute Snortum wrote:Does this site help? I found it by googling java 8 date to instant.
Dave Tolls wrote:That error looks to me like you are trying to do a PreparedStatement.setString passing in an object of type nl.mycumpanie.tk.dao.TkTimestamp.
Which looks wrong.
What does that bit of code look like?
You shouldn't have to worry about formats for any of these, if your column is a DATE or TIMESTAMP column (or equivalent), and you are setting it using PreparedStatement.setDate (or setTimestamp).
Dave Tolls wrote:You just pass the Date or Timestamp into the PreparedStatement.
In this case, into the Object of values you seem to be using, rather than using that getTimestampString method.
Paul Clapham wrote:Why isn't the system default ZoneId what you want? If it is what you want, then instead of
instead you use
Daan Heuvelbeuk wrote:It was the first time I worked with ZoneId, so I did not know (find, see) the option systemDefault();