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

org.nustaq.serialization.serializers.FSTTimestampSerializer Maven / Gradle / Ivy

Go to download

A fast java serialization drop in-replacement and some serialization based utils such as Structs and OffHeap Memory.

There is a newer version: 3.0.4-jdk17
Show newest version
package org.nustaq.serialization.serializers;

import java.io.IOException;

import org.nustaq.serialization.FSTBasicObjectSerializer;
import org.nustaq.serialization.FSTClazzInfo;
import org.nustaq.serialization.FSTClazzInfo.FSTFieldInfo;
import org.nustaq.serialization.FSTObjectInput;
import org.nustaq.serialization.FSTObjectOutput;

public class FSTTimestampSerializer extends FSTBasicObjectSerializer {

    @Override
    public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo,
                            FSTFieldInfo referencedBy, int streamPosition) throws IOException {
        out.writeLong(((java.sql.Timestamp)toWrite).getTime());
    }

    @Override
    public boolean alwaysCopy(){
        return true;
    }

    @Override
    public Object instantiate(Class objectClass, FSTObjectInput in, FSTClazzInfo serializationInfo,
                              FSTClazzInfo.FSTFieldInfo referencee, int streamPosition) throws Exception {
        long l = in.readLong();
        Object res = new java.sql.Timestamp(l);
        return res;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy