Package utils
Class TimestampTzConverter
java.lang.Object
utils.TimestampTzConverter
Bridges MEOS
TimestampTz values and java.time types.
A MEOS TimestampTz is a signed 64-bit count of microseconds since the
PostgreSQL epoch. This class converts that count to and from OffsetDateTime
and LocalDateTime, applying both the epoch offset and the microsecond unit.
Timezone resolution stays in MEOS: a timestamp string is parsed by
pg_timestamptz_in; this class only converts the numeric TimestampTz.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final longUnix seconds at the PostgreSQL epoch.private static final longprivate static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static InstanttoInstant(long ts) static LocalDateTimetoLocalDateTime(long ts) Converts a MEOSTimestampTzto aLocalDateTimein UTC.static OffsetDateTimetoOffsetDateTime(long ts) Converts a MEOSTimestampTzto anOffsetDateTimein UTC.static longConverts aLocalDateTime, taken as UTC, to a MEOSTimestampTz.static longConverts anOffsetDateTimeto a MEOSTimestampTz(microseconds since the PostgreSQL epoch).
-
Field Details
-
EPOCH_UNIX_SECONDS
private static final long EPOCH_UNIX_SECONDSUnix seconds at the PostgreSQL epoch.- See Also:
-
MICROS_PER_SECOND
private static final long MICROS_PER_SECOND- See Also:
-
NANOS_PER_MICRO
private static final long NANOS_PER_MICRO- See Also:
-
-
Constructor Details
-
TimestampTzConverter
private TimestampTzConverter()
-
-
Method Details
-
toTimestampTz
Converts anOffsetDateTimeto a MEOSTimestampTz(microseconds since the PostgreSQL epoch). -
toTimestampTz
Converts aLocalDateTime, taken as UTC, to a MEOSTimestampTz. -
toOffsetDateTime
Converts a MEOSTimestampTzto anOffsetDateTimein UTC. -
toLocalDateTime
Converts a MEOSTimestampTzto aLocalDateTimein UTC. -
toInstant
-