junit - SOAP REQUEST - Cannot parse date

476 views Asked by At

I am trying to execute a junit test on my deployed web service.But while passing the existing soap request as parameter to my deployed method I am getting the following error.

com.thoughtworks.xstream.converters.ConversionException: Cannot parse date 2016-12-09

I am using the following request.

<com.sampleclass>
<remark>TEST</remark>
<toDate>2016-12-09</toDate>
</com.sampleclass>

While my variable in the corresponding data class is.

private Date toDate;
1

There are 1 answers

2
Irham Iqbal On

It seems problem with you date format your passing. You have two ways to overcome this issue.

  1. Set the date in a format what is the library supports default.
  2. Register your own format XStream xstream = new XStream(); String dateFormat = "yyyy-MM-dd"; String[] acceptableFormats = {"yyyy-MM-dd"}; xstream.registerConverter(new DateConverter(dateFormat, acceptableFormats));

Thanks,

Irham