I have POJO attribute as below,

```
 @Column(name = "timeStamp")
 private LocalDateTime timeStamp;

```

This attribute coming from a service, and need to retain the format. I am streaming input from Kafka and need to store in Cassandra.

I'm creating table using datastax API,

```

CreateTable createTable = SchemaBuilder.createTable("sample31", "contactNew")
                    .ifNotExists()
                    .withColumn("timeStamp", DataTypes.TIMESTAMP);

```

When my job execution, am facing the below exception,

```
Codec not found for requested operation: [timestamp <-> java.time.LocalDateTime]

```

I tried with different data type such as `DataTypes.DURATION` , `DataTypes.DATE` not working.
['https://Stackoverflow.com/questions/63394559', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2182920/']
For Java driver 3.x you need to use a separate package - so-called "Optional codecs" by including an additional dependency:

```xml
<dependency>
  <groupId>com.datastax.cassandra</groupId>
  <artifactId>cassandra-driver-extras</artifactId>
  <version>driver-version</version>
</dependency>

```

For `LocalDateTime` from Java 8 there is a `LocalDateTimeCodec` ([doc](https://docs.datastax.com/en/developer/java-driver/3.8/manual/custom_codecs/extras/#jdk-8)) that should be registered when you created a cluster object, like this:

```java
import com.datastax.driver.extras.codecs.jdk8.LocalDateTimeCodec;

cluster.getConfiguration().getCodecRegistry()
    .register(LocalDateTimeCodec.instance);

```

There is similar codecs for Java driver 4.x, starting with driver 4.8. Also just register necessary codec as [described in documentation](https://docs.datastax.com/en/developer/java-driver/4.8/manual/core/custom_codecs/#mapping-cql-timestamps-to-local-date-time). But the easiest way is to register all necessary codecs at the session build time with something like this:

```java
CqlSession session = CqlSession.builder().addTypeCodecs()....build();

```
Just convert it to Instant and it will be mapped automatically:

```
message.getLocalDateTime().toInstant(ZoneOffset.UTC)

```