I have a WCF Service that returns a List of objects to an Android app. One of the properties is a DateTime property. The return format is JSON and I am getting the date in this format /Date(1441117247253+0200)/
on the Android side. I am using com.squareup.retrofit:retrofit:1.9.0 to get the data from my service.
I have no clue how to use Retrofit to create a the string date into a Date object. I had a look at this http://square.github.io/retrofit/ under the Custom Converters section, but do not know how to go further. This is what I've tried but I do not know how to implement the converter class.
creating the restAdapter like so:
restAdapter = new RestAdapter.Builder()
.setConverter(new DotNetDateConverter())
.setLogLevel(RestAdapter.LogLevel.FULL)
.setEndpoint(API).build();
and the DotNetDateConverter Class which I do not know how to implement further:
public class DotNetDateConverter implements Converter
{
@Override
public Object fromBody(TypedInput body, Type type) throws ConversionException
{
return null;
}
@Override
public TypedOutput toBody(Object object)
{
return null;
}
}
there are other fields in the response which are fine, but how do I change the /Date(1441117247253+0200)/
to a proper java.util.Date object? Without the converter I get com.google.gson.JsonSyntaxException:/Date(1441117247253+0200)/
obviously because the string cannot be converter to a date.
Any assistance would greatly be appreciated.