Ishank Gulati
Ishank Gulati

Reputation: 655

How to import custom QueryStringBindable in play 2.6

I have written a QueryStringBindable for joda DateTime like this:

object Binders {
  val pattern = "yyyy-MM-dd"

  implicit object jodaDateTimeBinder extends QueryStringBindable.Parsing[DateTime] (
    DateTimeFormat.forPattern(pattern).parseDateTime, _.toString, (k: String, e: Exception) =>
      "Cannot parse %s as DateTime: %s".format(k, e.getMessage())
  )
}

and I am importing it in build.sbt

routesImport += "com.xyz.utils._"

but during compilation I am still getting errors:

No QueryString binder found for type org.joda.time.DateTime. Try to implement an implicit QueryStringBindable for this type.

Can anyone point out what's wrong here?

Upvotes: 1

Views: 714

Answers (1)

bloopbloop
bloopbloop

Reputation: 31

I think I had a similar issue with ZonedDateTime. I had to add the imports to build.sbt. Perhaps you can try the same with org.joda.time.DateTime.

routesImport ++= Seq(
  "utils.Binders._",
  "java.sql.Date",
  "java.time.LocalDate",
  "java.time.ZonedDateTime",
  "model.dto._"
)

Upvotes: 3

Related Questions