kamikat / moshi-jsonapi

JSON API v1.0 Specification in Moshi.
MIT License
156 stars 34 forks source link

Date format issue #35

Closed deshmukhrohit11 closed 7 years ago

deshmukhrohit11 commented 7 years ago

I am newbie to moshi-jsonapi.

I am using JSONAPI in my project. I have one attribute of Date. I am getting error for it.

java.lang.IllegalArgumentException: Platform class java.util.Date annotated [] requires explicit JsonAdapter to be registered

Any one have any idea?

kamikat commented 7 years ago

An extra Date adapter should be add to moshi instance for things to work.

If you're using RFC3339, add com.squareup.moshi:moshi-adapters to project dependencies and use Rfc3339DateJsonAdapter:

Moshi moshi = new Moshi.Builder()
    ...
    .add(Date.class, new Rfc3339DateJsonAdapter())
    .build();

Otherwise, create custom JsonAdapter and add that to moshi likewise.

deshmukhrohit11 commented 7 years ago

Thank you. It work like charm..