0

We are facing issue for writing Timestamp into Gemfire Region

We are fetching the data from the DB2 table and putting them into Gemfire region.

One timestamp typed column is in the DB2 table

For the region of the Gemfire, we have specified java.sql.Timestamp type of field for Timestamp value.

From DB2 we are getting value for that field like 1993-01-01-08.23.35.148153

We uses PdxSerilizer for serializing and deserializing the data.

For writing the data into Gemfire, writeObject(String fieldName, Object value) of PdxWriter used.

After writing the data into region we are getting value in two part:

nanos   148000000   
time    725898215148

For nanosecond, the value got trimmed at the time of writing the data into the Gemfire.

We want the value of nano second same as it is in the DB2 table.

Milan Thummar
  • 261
  • 1
  • 2
  • 11

1 Answers1

1

To serialize java.sql.Timestamp GemFire/Geode converts it to a long by calling getTime() method. According to the javadocs for Timestamp that gets you the milliseconds from epoch. If you want to preserve nanos, you will have to write an implementation of PDXSerializer.

Swapnil
  • 1,191
  • 7
  • 8
  • I am using that PDXSerilizer's toData and fromData. See in document, PdxWriter is an argumnet of toData method. Did you implement this kind of scenarion? – Milan Thummar May 26 '17 at 07:07
  • You will need to write the nanos separately in your toData. After writing the timestamp, get the nanos and write the nanos. In your fromData method, you will read the nanos and then the converted timestamp. Then add the nanos back in. – Wes Williams May 26 '17 at 16:01