Created
April 20, 2016 17:40
-
-
Save williamho/2e60bf9635d2cfd504140eb9eadcd67b to your computer and use it in GitHub Desktop.
custom date reads
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
scala> import org.joda.time._ | |
import org.joda.time._ | |
scala> val j = Json.obj("date" -> "2012-08-16 17:52:20") | |
j: play.api.libs.json.JsObject = {"date":"2012-08-16 17:52:20"} | |
scala> implicit val dateReads = Reads.jodaDateReads("yyyy-MM-dd HH:mm:ss") | |
dateReads: play.api.libs.json.Reads[org.joda.time.DateTime] = play.api.libs.json.DefaultReads$$anon$22@3e886411 | |
scala> (j \ "date").as[DateTime] | |
res5: org.joda.time.DateTime = 2012-08-16T17:52:20.000-04:00 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment