-
-
Save kpmeen/0c278834a877115659ea to your computer and use it in GitHub Desktop.
Joda DateTime Serializer for ReactiveMongo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foo | |
import reactivemongo.bson.{BSONHandler, BSONDateTime, Macros} | |
import org.joda.time.format.ISODateTimeFormat | |
import org.joda.time.{DateTime, DateTimeZone} | |
package object bar { | |
DateTimeZone.setDefault(DateTimeZone.UTC) | |
implicit object BSONDateTimeHandler extends BSONHandler[BSONDateTime, DateTime] { | |
val fmt = ISODateTimeFormat.dateTime() | |
def read(time: BSONDateTime) = new DateTime(time.value) | |
def write(jdtime: DateTime) = BSONDateTime(jdtime.getMillis) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment