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

org.mapdb.serializer.SerializerDate Maven / Gradle / Ivy

Go to download

MapDB provides concurrent Maps, Sets and Queues backed by disk storage or off-heap memory. It is a fast, scalable and easy to use embedded Java database.

There is a newer version: 3.1.0
Show newest version
package org.mapdb.serializer;

import org.mapdb.DataInput2;
import org.mapdb.DataOutput2;

import java.io.IOException;
import java.util.Arrays;
import java.util.Date;

/**
 * Created by jan on 2/28/16.
 */
public class SerializerDate extends SerializerEightByte {

    @Override
    public void serialize(DataOutput2 out, Date value) throws IOException {
        out.writeLong(value.getTime());
    }

    @Override
    public Date deserialize(DataInput2 in, int available) throws IOException {
        return new Date(in.readLong());
    }

    @Override
    protected Date unpack(long l) {
        return new Date(l);
    }

    @Override
    protected long pack(Date l) {
        return l.getTime();
    }

    @Override
    final public int valueArraySearch(Object keys, Date key) {
        //TODO valueArraySearch versus comparator test
        long time = key.getTime();
        return Arrays.binarySearch((long[])keys, time);
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy