Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's what I have used successfully. I believe I used the info at the link mentioned in the first post. </p> <pre><code>import java.lang.reflect.Constructor; import org.joda.time.DateTime; import com.thoughtworks.xstream.converters.Converter; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.converters.UnmarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamReader; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; public final class JodaTimeConverter implements Converter { @Override @SuppressWarnings("unchecked") public boolean canConvert(final Class type) { return (type != null) &amp;&amp; DateTime.class.getPackage().equals(type.getPackage()); } @Override public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) { writer.setValue(source.toString()); } @Override @SuppressWarnings("unchecked") public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) { try { final Class requiredType = context.getRequiredType(); final Constructor constructor = requiredType.getConstructor(Object.class); return constructor.newInstance(reader.getValue()); } catch (final Exception e) { throw new RuntimeException(String.format( "Exception while deserializing a Joda Time object: %s", context.getRequiredType().getSimpleName()), e); } } } </code></pre> <p>You can register it like: </p> <pre><code>XStream xstream = new XStream(new StaxDriver()); xstream.registerConverter(new JodaTimeConverter()); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload