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

com.jfirer.fse.serializer.extra.UtilDateSerializer Maven / Gradle / Ivy

The newest version!
package com.jfirer.fse.serializer.extra;

import com.jfirer.fse.*;

import java.util.Date;

public class UtilDateSerializer extends CycleFlagSerializer implements FseSerializer
{
    @Override
    public void init(Class type, SerializerFactory serializerFactory)
    {
    }

    @Override
    public void writeToBytes(Object o, int classIndex, InternalByteArray byteArray, FseContext fseContext, int depth)
    {
        byteArray.writeVarInt(classIndex);
        long time = ((Date) o).getTime();
        byteArray.writeVarLong(time);
    }

    @Override
    public Object readBytes(InternalByteArray byteArray, FseContext fseContext)
    {
        long l    = byteArray.readVarLong();
        Date date = new Date(l);
        return date;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy