diff --git a/KotlinOutputFiles/DateFactory.kt b/KotlinOutputFiles/DateFactory.kt index 165eca2..1f719f5 100644 --- a/KotlinOutputFiles/DateFactory.kt +++ b/KotlinOutputFiles/DateFactory.kt @@ -6,15 +6,20 @@ import java.lang.reflect.Type class DateFactory : JsonAdapter.Factory { - override fun create(type: Type, annotations: MutableSet, moshi: Moshi): JsonAdapter<*>? { - return when (type.typeName) { - DateTime::class.java.typeName -> DateTimeJsonAdapter(getPatterns(annotations)) - LocalDate::class.java.typeName -> LocalDateJsonAdapter(getPatterns(annotations)) + override fun create(type: Type, annotations: Set, moshi: Moshi): JsonAdapter<*>? { + val typeName = when(type) { + is Class<*> -> type.canonicalName + else -> type.toString() + } + + return when (typeName) { + DateTime::class.java.canonicalName -> DateTimeJsonAdapter(getPatterns(annotations)) + LocalDate::class.java.canonicalName -> LocalDateJsonAdapter(getPatterns(annotations)) else -> null } } - private fun getPatterns(annotations: MutableSet) = annotations + private fun getPatterns(annotations: Set) = annotations .map { it as? Format } .firstOrNull() ?.patterns