Does anyone know how to convert this code to kotlin
GsonBuilder builder = new GsonBuilder();
builder.setLenient();
builder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
@Override
public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
if (json.getAsJsonPrimitive().isNumber()) {
return new Date(json.getAsJsonPrimitive().getAsLong() * 1000);
} else {
return null;
}
}
});
return builder.create();
Then i tried
val builder = GsonBuilder()
builder.setLenient()
builder.registerTypeAdapter(Date::class.java,.........)
return builder.create()
..... I can not figure out how to convert the code
source
share