I ran your code in my Intellij Idea, got the same error. I tried to debug the cause, but the call stack is so deep that I finally gave up. But perhaps this is because Lift does not provide a default format for LocaleDateTime, like the message mentioned, "this is the DateParser format that uses the default by default."
Here is a compromise for your reference, Lift-JSON provides a default date format for us
// net.liftweb.json.Serialization Line 72 def formats(hints: TypeHints) = new Formats { val dateFormat = DefaultFormats.lossless.dateFormat override val typeHints = hints }
Therefore, instead of completely writing a custom serializer, we can also change our data type to fit the default date format. In addition, net.liftweb.mongodb.DateSerializer (line 79) provides date serialization support.
Then we can provide a method to easily get LocaleDateTime. This is how I try to figure it out.
package jacoffee.scalabasic import java.time.{ ZoneId, LocalDateTime } import java.util.Date // package object defined is for Scala compiler to look for implicit conversion for case class parameter date package object stackoverflow { implicit def toDate(ldt: LocalDateTime): Date = Date.from(ldt.atZone(ZoneId.systemDefault()).toInstant()) implicit def toLDT(date: Date): LocalDateTime = LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()) } package jacoffee.scalabasic.stackoverflow import java.time.LocalDateTime import java.util.Date import net.liftweb.json.{ NoTypeHints, Serialization } import net.liftweb.json.Serialization.{ read, write } case class Child(var str: String, var Num: Int, var abc: Option[String], myList: List[Int], val date : Date = LocalDateTime.now()) { def getLDT: LocalDateTime = date } object DateTimeSerialization extends App { implicit val formats = Serialization.formats(NoTypeHints) val ser = write(Child("Mary", 5, None, List(1, 2))) // Child class converted to string {"str":"Mary","Num":5,"myList":[1,2],"date":"2015-07-21T03:07:05.699Z"} println(" Child class converted to string " + ser) var obj=read[Child](ser) // Object of Child is Child(Mary,5,None,List(1, 2),Tue Jul 21 11:48:22 CST 2015) println(" Object of Child is "+ obj) // LocalDateTime of Child is 2015-07-21T11:48:22.075 println(" LocalDateTime of Child is "+ obj.getLDT) }
Anyway, hope this helps.