title: Avro write java.sql.Timestamp conversion error
body: <p>I need to write a timestamp to Kafka partition and then read it from it. I have defined an Avro schema for that:</p>
  
  <pre><code>{ "namespace":"sample",
    "type":"record",
    "name":"TestData",
    "fields":[
      {"name": "update_database_time", "type": "long", "logicalType": "timestamp-millis"}
    ]
  }
  </code></pre>
  
  <p>However, I get a conversion error in the producer.send line:</p>
  
  <pre><code>java.lang.ClassCastException: java.sql.Timestamp cannot be cast to java.lang.Long
  </code></pre>
  
  <p>How can I fix this?</p>
  
  <p>Here is the code for writing timestamp to Kafka:</p>
  
  <pre><code>    val tmstpOffset = testDataDF
        .select("update_database_time")
        .orderBy(desc("update_database_time"))
        .head()
        .getTimestamp(0)
  
      val avroRecord = new GenericData.Record(parseAvroSchemaFromFile("/avro-offset-schema.json"))
      avroRecord.put("update_database_time", tmstpOffset)
  
      val producer = new KafkaProducer[String, GenericRecord](kafkaParams().asJava)
      val data = new ProducerRecord[String, GenericRecord]("app_state_test7", avroRecord)
      producer.send(data)
  </code></pre>