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

ru.sadv1r.vk.parser.UnixTimestampDeserializer.kt Maven / Gradle / Ivy

The newest version!
package ru.sadv1r.vk.parser

import com.fasterxml.jackson.core.JsonParser
import com.fasterxml.jackson.databind.DeserializationContext
import com.fasterxml.jackson.databind.JsonDeserializer
import java.sql.Timestamp
import java.util.*
import java.util.concurrent.TimeUnit

/**
 * Кастомный десериализатор Unix Timestamp
 *
 * Created on 4/3/16.
 *
 * @author sadv1r
 * @version 0.1
 */
class UnixTimestampDeserializer: JsonDeserializer() {
    override fun deserialize(parser:JsonParser, context:DeserializationContext):Date {
        val unixTimestamp = parser.text.trim()
        return Timestamp(TimeUnit.SECONDS.toMillis(unixTimestamp.toLong()))
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy