Created
May 2, 2016 21:16
-
-
Save ryanpbrewster/aeb0c66e31a7b51815d2d1a9c42cd0ce to your computer and use it in GitHub Desktop.
Format[DateTime] for Working with JSON in Play 2.1 by Greg Methvin.scala
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
| import play.api.libs.json._ | |
| val pattern = "yyyy-MM-dd'T'HH:mm:ssz" | |
| implicit val dateFormat = Format[DateTime]( | |
| Reads.jodaDateReads(pattern), | |
| Writes.jodaDateWrites(pattern) | |
| ) | |
| Json.toJson(new DateTime("1952-03-11")) | |
| // => "1952-03-11T00:00:00PDT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment