<a id="timestamprouter"></a>

# Kafka Connect TimestampRouter SMT Usage Reference for Confluent Platform

The `TimestampRouter` SMT (`org.apache.kafka.connect.transforms.TimestampRouter`)
updates an Apache Kafka® record’s topic field based on the original topic value and
the record timestamp.

## Description

`TimestampRouter` updates a record’s topic field using the record timestamp.
This is useful for sink connectors, because the topic field often determines
the equivalent entity name in the destination system such as a database
table or search index name.

To extract the timestamp from a specified message field, see
[Kafka Connect MessageTimestampRouter SMT Usage Reference for Confluent Platform](messagetimestamprouter.md#messagetimestamprouter). To convert the format of a timestamp field, see
[Kafka Connect TimestampConverter SMT Usage Reference for Confluent Platform](timestampconverter.md#timestampconverter).

<a id="timestamprouter-properties"></a>

## Properties

| Name               | Description                                                                                                                                                                                                      | Type   | Default                 | Valid values   | Importance   |
|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|-------------------------|----------------|--------------|
| `timestamp.format` | Format string for the timestamp that is compatible with `java.text.SimpleDateFormat`. For additional details, see [SimpleDateFormat](https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html). | string | yyyyMMdd                |                | high         |
| `topic.format`     | Format string which can contain `${topic}` and `${timestamp}` as placeholders for the topic and timestamp, respectively.                                                                                         | string | `${topic}-${timestamp}` |                | high         |

## Example: Add a timestamp to the topic

This configuration snippet shows how to use `TimestampRouter` to route
messages to topics and include a formatted timestamp.

```json
"transforms": "TimestampRouter",
"transforms.TimestampRouter.type": "org.apache.kafka.connect.transforms.TimestampRouter",
"transforms.TimestampRouter.topic.format": "foo-${topic}-${timestamp}",
"transforms.TimestampRouter.timestamp.format": "YYYYMM"
```

Before: `ordersTopic`

After: `foo-ordersTopic-201804`

## Predicates

Configure transformations with predicates to ensure they process only records
that satisfy a particular condition. You can also use predicates in a
transformation chain with the [Kafka Connect Filter (Kafka) SMT Usage Reference for Confluent Platform](filter-ak.md#ak-filter) to conditionally filter specific
records. For more information, see [Predicates](filter-ak.md#predicates).
