Skip to content

Instantly share code, notes, and snippets.

@DipaliShah
DipaliShah / CustomDateAdapter.kt
Created November 14, 2019 06:08
A custom Date formatter to format dates coming from Server in Moshi Way. An alternative to GSON builder .setDateFormat method as there is no resembling method in Moshi we need to create Adapter for this.
// Custom Type Adapters for Moshi
val userMoshi = Moshi.Builder().add(CustomDateAdapter()).add(T).build()
//add Moshi builder in Converter Facrory
val retrofit = Retrofit.Builder()
.baseUrl("https://dl.dropboxusercontent.com/")
.addConverterFactory(MoshiConverterFactory.create(userMoshi))
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build()