I am using grails 2.2 with mysql.
I get the time as unix timestamp.
def raceStartTime = params.raceStart //milliseconds epoch time
I then convert the time to date as shown below
Date startDateTime = new Date(raceStartTime.toLong())
and persist it in database
Race r = new Race()
r.start = startDateTime
r.save()
It turns out when saving the date in mysql database the precision is lost i.e the exact value of milliseconds is not recorded. It seems to record time as hh mm ss. I need to preserve the fractional part of the second. Is there a way to make it so that when the timestamp converted date is saved, the fractional second part is not lost? Thanks for help!
UPDATE:
I used the following mapping block to change the datatype.
static mapping = {
debug type: 'text'
raceStart sqlType: 'DATETIME(6)'
raceEnd sqlType: 'DATETIME(6)'
}
After this i run dbm-gorm-diff but it doesnt generate change log. i appreciate any guide.thanks!