Class Timestamp

java.lang.Object
org.apache.beam.sdk.schemas.logicaltypes.Timestamp
All Implemented Interfaces:
Serializable, Schema.LogicalType<Instant,Row>

public class Timestamp extends Object implements Schema.LogicalType<Instant,Row>
A timestamp represented with configurable precision.

This logical type stores timestamps as a Row with two fields:

  • seconds: INT64 - seconds since Unix epoch (can be negative)
  • subseconds: INT16 or INT32 - always non-negative (0 to 10^precision - 1)

The subseconds field is always non-negative, even for timestamps before the epoch. For example, -1.5 seconds is represented as {seconds: -2, subseconds: 500000} for microsecond precision. This matches Java's Instant internal representation.

Note for users converting from single-integer timestamp representations: If you have timestamps stored as a single long value (e.g., microseconds since epoch), you must handle negative modulo correctly when converting:


 long timestampMicros = -1_500_000;
 long seconds = timestampMicros / 1_000_000;
 long micros = timestampMicros % 1_000_000;
 if (micros < 0) {
   micros += 1_000_000;
   seconds -= 1;
 }
 Instant instant = Instant.ofEpochSecond(seconds, micros * 1000);
 
See Also: