Thursday, 2 November 2017

Play 2.6.x: Joda DateTime Format not working

In Play Framework 2.6.x, Joda DateTime Format (that is READs and WRITEs) is not working. When we use something like below:

(JsPath \ "joiningDate").read[LocalDate] 

We will see the following error message:

No Json deserializer found for type org.joda.time.LocalDate. Try to implement an implicit Reads or Format for this type.

To fix that issue, we need to do the following two setps:

1. Add the following entry into your build.sbt file

libraryDependencies += "" % "play-json-joda_2.12" % "2.6.6"


scalaVersion := "2.12.2"
libraryDependencies += "" %% "play-json-joda" % "2.6.6"

2. Add the following imports to your Model file
import play.api.libs.json.JodaWrites._
import play.api.libs.json.JodaReads._

They have separated the Joda Date and Time library into a separate module:

That's it.

Thank you for reading my tutorials.