Search code examples
javaxmltimestampxstreamdatetime-format

How can I format java.sql.Timestamp in a XML way using XStream?


I have some Java objects that I want to transform to XML. Some of the objects has a field java.sql.Timestamp datetime and I want them formatted in XML as datetimes is usually formatted in XML.

From what I know datetimes in XML should contain a T or a Z for UTC time. But if I use XStream the java.sql.Timestamp is formatted as <datetime>2011-04-20 14:24:29.334</datetime> in the XML.

Is there any way I can format Timestamps in a XML-way using XStream?


Solution

  • You can do it using Custom Converter