All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tianyisoft.database.jackson.LocalDateTimeSerializer.kt Maven / Gradle / Ivy

The newest version!
package com.tianyisoft.database.jackson

import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.databind.JsonSerializer
import com.fasterxml.jackson.databind.SerializerProvider
import java.io.IOException
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter


class LocalDateTimeSerializer : JsonSerializer() {
    private val format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")

    @Throws(IOException::class)
    override fun serialize(value: LocalDateTime, gen: JsonGenerator, serializers: SerializerProvider) {
        gen.writeString(value.format(format))
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy