Skip to content

Instantly share code, notes, and snippets.

@khajavi
Created January 29, 2019 08:53
Show Gist options
  • Save khajavi/aaad11a87ec82507187294fe3dce66fd to your computer and use it in GitHub Desktop.
Save khajavi/aaad11a87ec82507187294fe3dce66fd to your computer and use it in GitHub Desktop.
Add custom formatter for json4s
import org.json4s._
import org.json4s.jackson.JsonMethods._
implicit val formats: DefaultFormats = new DefaultFormats {
override def dateFormatter: SimpleDateFormat = {
val f = new SimpleDateFormat("EEE MMM dd HH:mm:ss ZZZZZ yyyy")
f.setTimeZone(DefaultFormats.UTC)
f
}
}
case class Event(startTime: java.sql.Timestamp, name: String)
val event: Event = parse("""{"startTime":"Sun Sep 30 17:42:40 +0000 2018", "name": "login"}""").extract[Event]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment