RetroRanch
New Member
I'm trying to get XStream to be able to convert a string that contains a datetime (such as \[code\]2013-01-23 16:50:39.495855\[/code\]) into a \[code\]java.lang.Long\[/code\] instance.Currently, I have XML like so:\[code\]<widget> <timestamp val="2013-01-23 16:50:39.495855"/></widget>\[/code\]I want to convert this into a standard Unix epoch timestamp (number of millis since Jan 1, 1970). Since the above datetime translates into a Unix epoch timestamp of (if my math is right) \[code\]1358959839000\[/code\], I'd like XStream to convert this into a \[code\]new Long(1358959839000)\[/code\] instance.I don't believe this is possible with XStream's alias methods, and I would probably need to write my own \[code\]Converter\[/code\], however a \[code\]com.thoughtworks.xstream.converters.basic.LongConverter\[/code\] already exists, so I'm not sure how to write my own \[code\]UnixEpochLongConverter\[/code\] seeing that both converters are attempting to convert a String to a Long. Any ideas? Thanks in advance!