Class IsoTime

java.lang.Object
io.debezium.time.IsoTime

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

The ISO 8601 time format includes the time (including fractional parts) and offset from UTC, such as '10:15:30Z'.

Author:
Ismail Simsek
See Also:
  • Field Details

  • Constructor Details

    • IsoTime

      private IsoTime()
  • Method Details

    • builder

      public static org.apache.kafka.connect.data.SchemaBuilder builder()
      Returns a SchemaBuilder for a IsoTime. The builder will create a schema that describes a field with the "io.debezium.time.IsoTime" as the name and
      invalid reference
      STRING
      for the literal type storing the time in UTC ISO 8601 format (e.g., "10:15:30Z").

      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 IsoTime but with all other default Schema settings. The schema describes a field with the "io.debezium.time.IsoTime" as the name and STRING for the literal type storing the time in UTC ISO 8601 format (e.g., "10:15:30Z").
      Returns:
      the schema
      See Also:
    • toIsoString

      public static String toIsoString(Object value, boolean acceptLargeValues)
      Converts a Duration, LocalTime, Date, Time, or Timestamp object to its UTC ISO 8601 string representation (e.g., "10:15:30Z").

      This method handles both Duration values and time-related objects. For Duration values, it ensures the resulting time is within the valid range (between 00:00:00 and 24:00:00 inclusive) by throwing an IllegalArgumentException if the duration goes beyond this range and the `acceptLargeValues` parameter is set to false. For time-related objects, it converts them to LocalTime before formatting.

      Parameters:
      value - the time or duration value; may not be null
      acceptLargeValues - whether to accept Duration values exceeding the valid range (00:00:00 - 24:00:00)
      Returns:
      the UTC ISO 8601 string representation of the time
      Throws:
      IllegalArgumentException - if the value is not an instance of the acceptable types, or if a Duration value exceeds the valid range and `acceptLargeValues` is false.