score:13

if you don't want to even construct a date object you could simply use this:

new java.sql.timestamp(system.currenttimemillis())

i would think this would be a tiny bit more efficient than using a new date(). but if you already have a date object you want to get the date from this will work for you.

new java.sql.timestamp(data.gettime())

score:16

why not something as simple as using date.gettime()?

new java.sql.timestamp(date.gettime)

you don't need joda time for this. scala isn't really relevant here, unless you need an implicit conversion:

//import once, use everywhere
implicit def date2timestamp(date: java.util.date) = 
    new java.sql.timestamp(date.gettime)

val date = new java.util.date

//conversion happens implicitly
val timestamp: java.sql.timestamp = date

Related Query