.. meta:: :description: This document provides usage information for the Apache Kafka SMT org.apache.kafka.connect.transforms.TimestampConverter. .. _timestampconverter: ================== TimestampConverter ================== The following provides usage information for the |ak-tm| SMT ``org.apache.kafka.connect.transforms.TimestampConverter``. Description ----------- Convert timestamps between different formats such as Unix epoch, strings, and |kconnect| Date/Timestamp types. Applies to individual fields or to the entire value. Use the concrete transformation type designed for the record key (``org.apache.kafka.connect.transforms.TimestampConverter$Key``) or value (``org.apache.kafka.connect.transforms.TimestampConverter$Value``). .. note:: The TimestampConverter SMT operates on one field at a time. Examples -------- This configuration snippet shows how to use ``TimestampConverter`` to transform a Unix epoch (represented as an ``int64`` value) into a formatted date string. .. code-block:: json "transforms": "TimestampConverter", "transforms.TimestampConverter.type": "org.apache.kafka.connect.transforms.TimestampConverter$Value", "transforms.TimestampConverter.format": "yyyy-MM-dd", "transforms.TimestampConverter.target.type": "string" Before: ``1696521093`` After: ``"2023-10-05"`` This configuration snippet shows how to use ``TimestampConverter`` to define the converter precision to microseconds. Note that there will be precision loss when converting values using microseconds or nanoseconds. .. code-block:: json "transforms.TimestampConverter.type": "org.apache.kafka.connect.transforms.TimestampConverter$Value", "transforms.TimestampConverter.field": "event_date_long", "transforms.TimestampConverter.unix.precision": "microseconds", "transforms.TimestampConverter.target.type": "Timestamp" Before: ``1696521093`` After: ``1696521093000000`` .. tip:: For additional examples, see `Timestamp Converter `__ for managed connectors. Properties ---------- .. list-table:: :header-rows: 1 :widths: 15 30 10 10 10 10 * - Name - Description - Type - Default - Valid Values - Importance * - ``target.type`` - The desired timestamp representation: string, unix, Date, Time, or Timestamp. - string - - - high * - ``field`` - The field containing the timestamp, or empty if the entire value is a timestamp. - string - `""` - - high * - ``format`` - Format string for the timestamp that is compatible with ``java.text.SimpleDateFormat``. Used to generate the output when type=string or used to parse the input if the input is a string. For additional details, see `SimpleDateFormat `_. - string - `""` - - medium * - ``unix.precision`` - The desired UNIX precision for the timestamp in seconds, milliseconds, microseconds, or nanoseconds. Note that there will be precision loss when converting values using microseconds or nanoseconds. - string - `""` - seconds, milliseconds (default), microseconds, nanoseconds - low .. include:: includes/predicate.rst