mysql - Storing joda datetime using slick, always stores UTC datetime -
i having problems storing datetime value in mysql db using slick, have case class this:
case class facebookshares( var id: int, var designid: int, var shareorgid: string, var sharerid: int, var sharedlink: string, var sharedtimestamp: instant, var shareddatetime: datetime, var modifiedtimestamp: instant) { def this() = this(0, 0, "", 0, "", datetime.now(datetimezone.forid("america/new_york")).toinstant, datetime.now(datetimezone.forid("america/new_york")), datetime.now.toinstant) }
and slick projection class:
class facebookshareprojection(tag: tag) extends table[facebookshares](tag, "facebook_shares_47") { def id: column[int] = column[int]("id", o.primarykey) def designid: column[int] = column[int]("fs_design_id") def shareorgid: column[string] = column[string]("fs_share_org_id") def sharerid: column[int] = column[int]("fs_sharer_id") def sharedlink: column[string] = column[string]("fs_shared_link") def sharedtimestamp: column[instant] = column[instant]("fs_shared_timestamp") def shareddatetime: column[datetime] = column[datetime]("fs_shared_datetime") def modifiedtimestamp: column[instant] = column[instant]("fs_modified_timestamp") def * : provenshape[facebookshares] = (id, designid, shareorgid, sharerid, sharedlink, sharedtimestamp, shareddatetime, modifiedtimestamp) <> ( ((facebookshares.apply _): (int, int, string, int, string, instant, datetime, instant) => facebookshares).tupled, facebookshares.unapply) }
now when try insert data, resultant date in mysql table shows timestamp of utc timezone, when have defined timezone "america/new_york"
def store() = { val timestamp = datetime.now(datetimezone.forid("america/new_york")).toinstant sqldb.withsession { implicit session => shareprojection += facebookshares(0, 0, "", 0, "", timestamp, datetime.now(datetimezone.forid("america/new_york")), datetime.now.toinstant) } }
why date being stored in utc timezone rather est timezone
Comments
Post a Comment