XStream and joda time

If you have the choice to use an alternative to java.util.Date you shoud look at Joda Time. Joda Time is date handling done right and is going to be used in Java 7 if I am not mistaken. We use it with good success in our project now.

We also serialize our objects using XStream which is a nice Object to XML framework which just does the trick, and for a long time we thought it was working out of the box. Last wednesday we run into a snag that after serializing Joda Time DateTime objects in one JVM and attempted to deserialize them in another it fails. After looking into it, it appears that XStream does a heroic attemt at serializing and deserializing DateTime objects, and it works fine if you are in the same JVM. Though when you do this across several JVM it fails.

To solve it I had to introduce custom serialization for DateTime and LocalDate, which serialize them into a nice formatted string insted of the internal structure of Joda Time.

|