aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/common.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/common.scala')
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/common.scala11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/common.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/common.scala
index fbb0258..4dadb11 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/common.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/common.scala
@@ -1,6 +1,7 @@
package xyz.driver.pdsuidomain.formats.json.sprayformats
-import java.time.{LocalDate, LocalDateTime}
+import java.time.format.DateTimeFormatter
+import java.time.{LocalDate, LocalDateTime, ZonedDateTime}
import spray.json._
import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId, StringId, UuidId}
@@ -39,6 +40,14 @@ object common {
}
}
+ implicit def zonedDateTimeFormat = new RootJsonFormat[ZonedDateTime] {
+ override def write(date: ZonedDateTime): JsString = JsString(date.toString)
+ override def read(json: JsValue): ZonedDateTime = json match {
+ case JsString(value) => ZonedDateTime.parse(value)
+ case _ => deserializationError(s"Expected date as ZonedDateTime, but got $json")
+ }
+ }
+
implicit def dateFormat = new RootJsonFormat[LocalDate] {
override def write(date: LocalDate): JsString = JsString(date.toString)
override def read(json: JsValue): LocalDate = json match {