Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ryanpbrewster/aeb0c66e31a7b51815d2d1a9c42cd0ce to your computer and use it in GitHub Desktop.

Select an option

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
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