Created
January 29, 2019 08:53
-
-
Save khajavi/aaad11a87ec82507187294fe3dce66fd to your computer and use it in GitHub Desktop.
Add custom formatter for json4s
This file contains 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 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