This discussion is archived
3 Replies Latest reply: Jan 2, 2013 4:29 PM by tmiddlet RSS

Date deserialized as java.sql.Timestamp

938865 Newbie
Currently Being Moderated
I seem to be having the same issue as mentioned in these two threads

java.util.Date badly serialized to java.sql.Timestamp Coherence 3.5.2
PofExtractor with java.util.Date results in ClassCastException

When i serialize a Date, it deserializes as a java.sql.Timestamp. According to one of those threads, this was fixed under bug COH-3297.

I'm using version 3.7.1-p5

-------------------------------
Test:

@Test
public void dateSerializationTest() {
          
Calendar cal = new GregorianCalendar(2012, 11, 18, 16, 10, 50);
Date original = cal.getTime();
     
ConfigurablePofContext pofContext = new ConfigurablePofContext();
Binary binary = ExternalizableHelper.toBinary(original, pofContext);
Date copy = (Date) ExternalizableHelper.fromBinary(binary, pofContext);

System.out.println(binary.toString());
System.out.println("Original - Type[" + original.getClass() + "] Value[" + original + "]");
System.out.println("Copy - Type[" + copy.getClass() + "] Value[" + copy + "]");

assertEquals(original, copy);
}

-------------------
Output:

Binary(length=11, value=0x15539C1F0C12100A320001)
Type[class java.util.Date] Value[Tue Dec 18 16:10:50 GMT 2012]
Type[class java.sql.Timestamp] Value[2012-12-18 16:10:50.0]


I cant find the bug tracking system to see if this is still an open bug.

cheers for any help

Rob

Edited by: Rob Fraser on 19-Dec-2012 02:08

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points