Package io.debezium.time
Class IsoTimestamp
java.lang.Object
io.debezium.time.IsoTimestamp
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.kafka.connect.data.SchemaBuilderbuilder()Returns aSchemaBuilderfor aIsoTimestamp.static org.apache.kafka.connect.data.Schemaschema()Returns a Schema for aIsoTimestampbut with all other default Schema settings.static StringtoIsoString(Object value, TemporalAdjuster adjuster) Converts aInstant(represented as milliseconds since epoch),LocalDateTime,Date,Timestamp, or any other object convertible to aLocalDateTimeto its UTC ISO 8601 string representation (e.g., "2011-12-03T10:15:30Z").
-
Field Details
-
SCHEMA_NAME
- See Also:
-
FORMATTER
-
-
Constructor Details
-
IsoTimestamp
private IsoTimestamp()
-
-
Method Details
-
builder
public static org.apache.kafka.connect.data.SchemaBuilder builder()Returns aSchemaBuilderfor aIsoTimestamp. The builder will create a schema that describes a field with the "io.debezium.time.IsoTimestamp" as thenameandSTRINGfor 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 aIsoTimestampbut with all other default Schema settings. The schema describes a field with the "io.debezium.time.IsoTimestamp" as thenameandwith the "io.debezium.time.IsoTimestamp" as theinvalid @link
{@link SchemaBuilder#nameandSTRINGfor 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
Converts aInstant(represented as milliseconds since epoch),LocalDateTime,Date,Timestamp, or any other object convertible to aLocalDateTimeto 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 aLocalDateTimein UTC. For other objects, it uses theConversions.toLocalDateTime(Object)method for conversion. If an adjuster is provided, it's used to adjust the resultingLocalDateTimebefore formatting it to the string representation.- Parameters:
value- the timestamp value; may not be nulladjuster- 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
-