# Timestamp deserialization fails because epoch is in milliseconds but expected in seconds

- **ID:** `data/timestamp-epoch-millis-vs-seconds`
- **Domain:** data
- **Category:** type_error
- **Error Code:** `TIMESTAMP_EPOCH_UNIT_MISMATCH`
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

The data source provides timestamps as Unix epoch milliseconds (e.g., 1700000000000) but the deserializer expects seconds (e.g., 1700000000), causing overflow or incorrect dates.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Apache Kafka 3.5.0 | active | — | — |
| Python datetime 3.11 | active | — | — |
| Java 17 | active | — | — |

## Workarounds

1. **Detect the unit by checking the magnitude: if timestamp > 1e12, treat as milliseconds and divide by 1000. Example in Python: `if ts > 1e12: ts /= 1000`.** (95% success)
   ```
   Detect the unit by checking the magnitude: if timestamp > 1e12, treat as milliseconds and divide by 1000. Example in Python: `if ts > 1e12: ts /= 1000`.
   ```
2. **Configure the deserializer to expect milliseconds explicitly, e.g., in Kafka Connect: `timestamp.converter=org.apache.kafka.connect.json.JsonConverter` with `converter.type=timestamp` and `converter.format=epoch.millis`.** (85% success)
   ```
   Configure the deserializer to expect milliseconds explicitly, e.g., in Kafka Connect: `timestamp.converter=org.apache.kafka.connect.json.JsonConverter` with `converter.type=timestamp` and `converter.format=epoch.millis`.
   ```

## Dead Ends

- **** — Dividing by 1000 in code may cause integer overflow if the timestamp is stored as a 32-bit integer. (70% fail)
- **** — Assuming all timestamps are in milliseconds may break when some sources use seconds. (80% fail)
