custom format in JSON for DateTimeField with mongorecord

im using lift-mongodb-record 2.4. All of my MongoRecord models include the following DateTimeField field, eg:

object created_at extends DateTimeField(this)

when i call asJSON on this model, it'll parse the date into a string e.g.

Mon, 16 Jul 2012 21:26:58 GMT

I would prefer other formats (eg. ISO 8601, depends on the acutal use-case)

how and where would I set up a custom format?



Overriding asJValue and setFromJValue should do the trick since the default implementation uses the so called internet date, like in the following:

val statusDate = new DateTimeField(this){

  val sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
  override def asJValue = {
    asJString(v => sdf.format(v.getTime))

  override def setFromJValue(jvalue: JValue) = setFromJString(jvalue) {
    v =>tryo {
      }.map(d => {
      val cal = Calendar.getInstance

Need Your Help