package space.nstart.pcp.pcp_types_lib.utils.json

import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.databind.JsonSerializer
import com.fasterxml.jackson.databind.SerializerProvider
import space.nstart.pcp.pcp_types_lib.utils.UtcDateTimes
import java.time.LocalDateTime

class LocalDateTimeTimeZoneSerializer: JsonSerializer<LocalDateTime?>() {

    override fun serialize(p0: LocalDateTime?, p1: JsonGenerator, p2: SerializerProvider) {
        if (p0 == null) {
            p1.writeNull()
        } else {
            p1.writeString(UtcDateTimes.format(p0))
        }
    }
}
