title: Casting cassandra timestamp column as timeuuid
body: <p>I'm getting events from <code>Kafka</code> and storing into <code>Cassandra</code>. Parsing <code>json</code> which contains fields <code>eventID, sessionID, timestamp, userID</code> to create columns for <code>Cassandra</code> table which looks like this:</p>
  
  <pre><code>cassandra@cqlsh&gt; CREATE TABLE mydata.events (
     ...     "event_date" date,
     ...     "eventID" text,
     ...     "userID" text,
     ...     timestamp timeuuid,
     ...     "sessionID" text,
     ...     "fullJson" text,
     ...     PRIMARY KEY ("event_date", timestamp, "sessionID")
  </code></pre>
  
  <p>and in code:</p>
  
  <pre><code>case class cassandraFormat(
                         eventID: String, 
                         sessionID: String,
                         timeuuid: UUID, // timestamp as timeuuid
                         userID: String,
                         event_date: LocalDate, // YYYY-MM-dd format
                         fullJson: String // full json from Kafka
                       )
  </code></pre>
  
  <p>I need to add <code>timestamp</code> column as <code>timeuuid</code>. Since I'm parsing from <code>json</code>, extracted all values from header and created columns in this fashion: </p>
  
  <pre><code> val allJson = rdd.
              map(x =&gt; {
                implicit val formats: DefaultFormats.type = org.json4s.DefaultFormats
                //use serialization default to format a Map to JSON
                (x, Serialization.write(x))
              }).
              filter(x =&gt; x._1 isDefinedAt "header").
              map(x =&gt; (x._1("header"), x._2)).
              filter(x =&gt; (x._1 isDefinedAt "userID") &amp;&amp;
                (x._1 isDefinedAt "eventID") &amp;&amp;
                (x._1 isDefinedAt "sessionID") &amp;&amp;
                (x._1 isDefinedAt "timestamp").
              map(x =&gt; cassFormat(x._1("eventID").toString,
                x._1("sessionID").toString,
                com.datastax.driver.core.utils.UUIDs.startOf(x._1("timestamp").toString.toLong),
                x._1("userID").toString,
                com.datastax.driver.core.LocalDate.fromMillisSinceEpoch(x._1("timestamp").toString.toLong),
                x._2))
  </code></pre>
  
  <p>This part: </p>
  
  <pre><code>com.datastax.driver.core.utils.UUIDs.startOf(x._1("timestamp").toString.toLong)
  </code></pre>
  
  <p>is generating Error </p>
  
  <blockquote>
    <p>java.lang.NumberFormatException: For input string:
    "2019-05-09T09:00:52.553+0000"    at
    java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)</p>
  </blockquote>
  
  <p>Even tried: 
             <code>java.util.UUID.fromString(x._1("timestamp").toString</code>,
  also generating same Error. 
  How to properly cast/convert <code>timestamp</code> as <code>timeuuid</code> and insert into <code>Cassandra</code> via spark job</p>