Eduardo M. Cavalcanti
unread,Jun 1, 2011, 4:40:02 PM6/1/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to orbroker
Hi,
I have coded these two converters, maybe they are useful to someone in
need.
In the case of the LocalDateTime converter the getLocalMillis method
is protected, so I have used a somewhat ugly path, but correct, I
think, to make the conversion.
The EnumerationValueConv converts to String the Values of any Scala
Enumeration.
Regards.
object JodaLocalDateTimeConv extends ParmConverter {
type T = org.joda.time.LocalDateTime
val fromType = classOf[T]
def toJdbcType(ts: T) = {
val jdkDate = ts.toLocalDate.toDateTimeAtStartOfDay.toDate
jdkDate.setHours(ts.getHourOfDay)
jdkDate.setMinutes(ts.getMinuteOfHour)
jdkDate.setSeconds(ts.getSecondOfMinute)
val jsts = new java.sql.Timestamp(jdkDate.getTime)
jsts.setNanos(ts.getMillisOfSecond * 1000000)
jsts
}
}
object EnumerationValueConv extends ParmConverter {
type T = Enumeration#Value
val fromType = classOf[T]
def toJdbcType(ts: T) = {
ts.toString
}
}