Scala, Sql Server - How To Insert The Current Timestamp As Datetime In Sql Server Using Scala?
I want to insert the current timestamp as datetime data type into sql server using Scala. So far I have tried this: import java.time.LocalDateTime import java.time.format.DateTime
Solution 1:
Provided that you are using JDBC 4.2 or higher (which I believe that most of us are):
myInsertStatement.setObject(1, currentTimeStamp)
LocalDateTime is a poor choice for a timestamp, though, because it doesn’t “know” its time zone and therefore is ambiguous as a point in time. While I don’t know SQL Server, for most database engines it would be better to use timestamp with timezone on the database side and OffsetDateTime on the Scala side.
Post a Comment for "Scala, Sql Server - How To Insert The Current Timestamp As Datetime In Sql Server Using Scala?"