Class IsoTimestamp

java.lang.Object
io.debezium.time.IsoTimestamp

public class IsoTimestamp extends Object
A utility for converting various Java timestamp representations into a UTC ISO 8601 string representation (including date, time, fractional parts, and offset from UTC), and for defining a Kafka Connect Schema for timestamp values in this format.

The ISO 8601 date-time format includes the date, time (including fractional parts), and offset from UTC, such as '2011-12-03T10:15:30Z'.

Author:
Ismail Simsek
See Also:
  • Field Details

  • Constructor Details

    • IsoTimestamp

      private IsoTimestamp()
  • Method Details

    • builder

      public static org.apache.kafka.connect.data.SchemaBuilder builder()
      Returns a SchemaBuilder for a IsoTimestamp. The builder will create a schema that describes a field with the "io.debezium.time.IsoTimestamp" as the name and STRING for the literal type storing the timestamp in UTC ISO 8601 format (e.g., "2023-11-21T18:29:26Z").

      You can use the resulting SchemaBuilder to set additional schema settings such as required/optional, default value, and documentation.

      Returns:
      the schema builder
    • schema

      public static org.apache.kafka.connect.data.Schema schema()
      Returns a Schema for a IsoTimestamp but with all other default Schema settings. The schema describes a field with the "io.debezium.time.IsoTimestamp" as the name and
      invalid @link
      {@link SchemaBuilder#
      with the "io.debezium.time.IsoTimestamp" as the name and STRING for the literal() STRING} for the literal type storing the timestamp in UTC ISO 8601 format (e.g., "2023-11-21T18:29:26Z").
      Returns:
      the schema
      See Also:
    • toIsoString

      public static String toIsoString(Object value, TemporalAdjuster adjuster)
      Converts a Instant (represented as milliseconds since epoch), LocalDateTime, Date, Timestamp, or any other object convertible to a LocalDateTime to its UTC ISO 8601 string representation (e.g., "2011-12-03T10:15:30Z").

      This method handles various timestamp-related objects. For Instant, it converts the milliseconds since epoch to a LocalDateTime in UTC. For other objects, it uses the Conversions.toLocalDateTime(Object) method for conversion. If an adjuster is provided, it's used to adjust the resulting LocalDateTime before formatting it to the string representation.

      Parameters:
      value - the timestamp value; may not be null
      adjuster - the optional component that adjusts the local date-time value before obtaining the string representation; may be null if no adjustment is necessary
      Returns:
      the UTC ISO 8601 string representation of the timestamp
      Throws:
      IllegalArgumentException - if the value is not an instance of the acceptable types