I try to get JSON from server by Retrofit 2 but I got this error:
com.google.gson.JsonSyntaxException: Mon Feb 29 08:12:40 GMT+00:00 2016
This is some line of code what I init the Gson and Retrofit :
Gson gson = new GsonBuilder()
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
.create();
Retrofit client = new Retrofit.Builder()
.baseUrl(AppConfig.BASE_URL)
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
RESTDatabaseDAO service = client.create(RESTDatabaseDAO.class);
Call<Message> call = service.getLastMessage(objectItem.getUserId(), AppConfig.USER_ID);
call.enqueue(new Callback<Message>() {
@Override
public void onResponse(Call<Message> call, Response<Message> response) {
if (response.isSuccess()) {
Message message = response.body();
Log.i("In retrofit method success message", response.body() + "");
viewHolder.tv_lastMessage.setText(message.getMessage());
} else {
Log.i("In retrofit method failure", response.body() + "");
}
}
@Override
public void onFailure(Call<Message> call, Throwable t) {
Log.i("In retrofit method failure message", t.toString());
}
});
This is my data in database:
Mon Feb 29 08:12:40 GMT+00:00 2016
UPDATE: This is my JSON String:
{"messageId":1,"message":"new","expiresTime":"Fri Mar 04 02:12:39 GMT+00:00 2016","senderId":2,"userId":1}