com.jfirer.fse.serializer.extra.UtilDateSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Fse Show documentation
Show all versions of Fse Show documentation
a high speed serilaize library
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;
}
}