Formatting

This commit is contained in:
Matthieu 2021-09-20 12:06:31 +02:00
parent dc402819d4
commit d93504c072
2 changed files with 3 additions and 15 deletions

View File

@ -47,9 +47,9 @@ interface PixelfedAPI {
)
} as JsonDeserializer<Instant>).registerTypeAdapter(
Instant::class.java,
JsonSerializer { src: Instant, _,_ ->
JsonPrimitive(DateTimeFormatter.ISO_INSTANT.format(src));
})
JsonSerializer { src: Instant, _, _ ->
JsonPrimitive(DateTimeFormatter.ISO_INSTANT.format(src))
})
.create()
private val intermediate: Retrofit.Builder = Retrofit.Builder()

View File

@ -5,7 +5,6 @@ import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import org.pixeldroid.app.utils.api.objects.*
import java.time.Instant
import java.time.OffsetDateTime
import java.time.format.DateTimeFormatter
import java.util.*
@ -25,17 +24,6 @@ class Converters {
fun fromInstant(time: Instant?): String? =
time?.let { instantFormatter.format(it) }
@TypeConverter
fun toOffsetDateTime(value: String?): OffsetDateTime? {
return value?.let {
return formatter.parse(it, OffsetDateTime::from)
}
}
@TypeConverter
fun fromOffsetDateTime(date: OffsetDateTime?): String? {
return date?.format(formatter)
}
@TypeConverter
fun listToJson(list: List<String>): String = gson.toJson(list)