XStream: Cannot parse date

I was sending date “06-14-2011” in XML request, during it’s processing i got this parse error

Cannot parse date 06-14-2011 com.thoughtworks.xstream.converters.basic.DateConverter.fromString(DateConverter.java:97)

this is because Xstream by default don’t handle MM-dd-yyyy format. So we need to add one in order to make our format working.

String[] formats ={“MM-dd-yyyy”}; XStream xstream = new XStream(); xstream.registerConverter(new DateConverter(“MM-dd-yyyy”,formats)); Object obj=xstream.fromXML(inputXML)

This will resolve the issue. =)

One Reply to “XStream: Cannot parse date”

Leave a Reply

Your email address will not be published. Required fields are marked *