All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.quantarray.anaheim.spray.json.LocalDateFormatting.scala Maven / Gradle / Ivy

package com.quantarray.anaheim.spray.json

import spray.json.{DeserializationException, JsString, JsValue, RootJsonFormat}

import java.time.LocalDate

trait LocalDateFormatting {

  implicit object LocalDateFormat extends RootJsonFormat[LocalDate] {

    override def write(ld: LocalDate): JsString = JsString(ld.toString)

    override def read(json: JsValue): LocalDate = json match {
      case JsString(s) => LocalDate.parse(s)
      case _ => throw DeserializationException(s"Cannot parse $json.")
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy