Date Codecs

By default, Scala-Cass uses the timestamp format provided as default for the Java driver. It is:

Cassandra Type Scala Type
timestamp java.util.Date

You have the option of using the Joda library or Jdk8 date library as a replacement for this default. While the examples below showcase how to read data of joda/jdk8 types, the same process is required for writing these types to Cassandra.

Joda Implicits

All you need to do is import the implicits required to understand the joda Instant, com.weather.scalacass.joda.Implicits._

scala> import com.weather.scalacass.syntax._, com.weather.scalacass.joda.Implicits._
import com.weather.scalacass.syntax._
import com.weather.scalacass.joda.Implicits._

scala> r // some row from your table
res3: com.datastax.driver.core.Row = Row[a primary key, Mon Jul 23 04:06:36 GMT 2018]

scala> r.as[org.joda.time.Instant]("mytimestamp") // cassandra "timestamp"
res4: org.joda.time.Instant = 2018-07-23T04:06:36.865Z

Jdk8 Implicits

All you need to do is import the implicits required to understand the jdk8 Instant, com.weather.scalacass.jdk8.Implicits._

scala> import com.weather.scalacass.syntax._, com.weather.scalacass.jdk8.Implicits._
import com.weather.scalacass.syntax._
import com.weather.scalacass.jdk8.Implicits._

scala> r // some row from your table
res5: com.datastax.driver.core.Row = Row[a primary key, Mon Jul 23 04:06:36 GMT 2018]

scala> r.as[java.time.Instant]("mytimestamp") // cassandra "timestamp"
res6: java.time.Instant = 2018-07-23T04:06:36.865Z