Converting date and times for a topic

Use the following syntax to configure date and time conversion parameters for each Pulsar topic.

topic:
  topic_name:
    codec:
      locale: en_US
      timeZone: UTC
      timestamp: CQL_TIMESTAMP
      date: ISO_LOCAL_DATE
      time: ISO_LOCAL_TIME
      unit: MILLISECONDS

where topic_name is the name of the Apache Pulsar™ topic.

Parameters

Configure the date and time settings to override the default. These settings apply per topic.

Date and time settings support any public static field in java.time.format.DateTimeFormatter as an option.
timestamp

The temporal pattern to use for string-to-CQL timestamp conversion, the choices are:

  • Date-time pattern such as yyyy-MM-dd HH:mm:ss.

  • Pre-defined formatter such as ISO_ZONED_DATE_TIME or ISO_INSTANT.

  • Special formatter CQL_TIMESTAMP parser that accepts all valid CQL literal formats for the timestamp type.

    Default: CQL_TIMESTAMP

date

The temporal pattern to use for string-to-CQL date conversion.

  • Date-time pattern such as yyyy-MM-dd.

  • Pre-defined formatter such as ISO_LOCAL_DATE.

    Default: ISO_LOCAL_DATE

time

The temporal pattern to use for string-to-CQL time conversion. Valid choices:

  • Date-time pattern, such as HH:mm:ss.

  • Pre-defined formatter, such as ISO_LOCAL_TIME.

    Default: ISO_LOCAL_TIME

unit

If the input is a string containing only digits that cannot be parsed using the codec.timestamp format, the specified time unit is applied to the parsed value. All TimeUnit enum constants are valid choices.

Default: MILLISECONDS

timeZone

The time zone to use for temporal conversions that do not convey any explicit time zone information.

Default: UTC

locale

Locale to use for locale-sensitive conversions.

Default: en_US

See DateTimeFormatter documentation for additional options.

Examples

Timezone example

To write to a column with data type timestamp, for the test Pulsar topic string field that contains 2018-03-09T17:12:32.584+01:00[Europe/Paris], use the setting:

topic:
  test:
    codec:
      timestamp: ISO_ZONED_DATE_TIME

Date example

To write to a column with type date for a Pulsar topic that contains a string field like "2018-04-12", use the setting:

topic:
  test:
    codec:
      date: "yyyy-MM-dd"

Time example

To write to a column with type time for a Pulsar topic string field like "10:15:30", use setting:

topic:
  test:
    codec:
      time: ISO_LOCAL_TIME

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com