You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "APA (Jira)" <ji...@apache.org> on 2024/10/21 08:03:00 UTC
[jira] [Created] (KAFKA-17842) Replace java.util.Date with java.time for microsecond/nanosecond precision and modern API usage
APA created KAFKA-17842:
---------------------------
Summary: Replace java.util.Date with java.time for microsecond/nanosecond precision and modern API usage
Key: KAFKA-17842
URL: https://issues.apache.org/jira/browse/KAFKA-17842
Project: Kafka
Issue Type: Improvement
Components: connect
Affects Versions: 3.8.0
Reporter: APA
**Problem**:
Apache Kafka Connect currently uses `java.util.Date` for timestamp handling, which only supports millisecond precision. This is insufficient for applications requiring microsecond or nanosecond precision, which are increasingly common in modern distributed systems. Additionally, `java.util.Date` is considered outdated and has several limitations, including being mutable and lacking thread safety.
**Proposed Solution**:
I propose replacing the usage of `java.util.Date` with the modern `java.time`API (introduced in Java 8), specifically using classes like `Instant` from `java.time`, which supports nanosecond precision. The `java.time` API is immutable, thread-safe, and provides more comprehensive date/time handling capabilities.
**Advantages**:
- Support for microsecond and nanosecond precision.
- Cleaner, modern API.
- Better time zone and time arithmetic handling.
- Improved thread safety with immutable date/time objects.
**Backward Compatibility**:
Care should be taken to ensure backward compatibility where necessary, potentially providing conversion utilities for legacy systems still using `java.util.Date`.
**Priority**:
This issue affects a lot of use cases nowadays and forces people to find workarounds today, adopting `java.time` would future-proof Kafka Connect and align it with modern Java development practices.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)