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

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

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

import com.jfirer.fse.*;

import java.util.Calendar;

public class CalendarSerializer 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);
        byteArray.writeVarLong(((Calendar) o).getTimeInMillis());
    }

    @Override
    public Object readBytes(InternalByteArray byteArray, FseContext fseContext)
    {
        long     l        = byteArray.readVarLong();
        Calendar instance = Calendar.getInstance();
        instance.setTimeInMillis(l);
        return instance;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy