Managing Timestamp Values on Multiple Sites
When multiple GemFire XD sites use WAN replication, applications must follow best practices to ensure that timestamp values are applied in a predictable way.
For example, if an application uses the JDBC call:
setTimestamp(int parameterIndex, Timestamp x)to generate and store a timestamp, then the originating GemFire XD site uses its default local time zone to calculate a SQL timestamp value. Each site that replicates the DML also uses its own local time zone to generate the SQL timestamp, so a site that is in a different time zone stores a different value. Without the original time zone information, there is no way for an application to determine the exact time when the original update took place.
As a best practice applications should specify a timezone when generating a timestamp value and store both the time zone and SQL timestamp in the table. For example:
setTimestamp(int parameterIndex, Timestamp x, Calendar cal)When retrieving a timestamp from the table, the recorded time zone can be used with the associated getter method, getTimestamp(int columnIndex, Calendar cal), to determine the exact time of the update.