com.tianyisoft.database.jackson.LocalDateTimeDeserializer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of querybuilder Show documentation
Show all versions of querybuilder Show documentation
A query builder from laravel
The newest version!
package com.tianyisoft.database.jackson
import com.fasterxml.jackson.core.JsonParser
import com.fasterxml.jackson.databind.DeserializationContext
import com.fasterxml.jackson.databind.JsonDeserializer
import java.io.IOException
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
class LocalDateTimeDeserializer : JsonDeserializer() {
private val format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
@Throws(IOException::class)
override fun deserialize(p: JsonParser, context: DeserializationContext?): LocalDateTime {
return LocalDateTime.parse(p.valueAsString, format)
}
}