RuedigerMoeller / fast-serialization

FST: fast java serialization drop in-replacement
Apache License 2.0
1.59k stars 247 forks source link

Build In Serialization for java.sql.Timestamp #230

Open martinrosstmc opened 6 years ago

martinrosstmc commented 6 years ago

Any chance that we can get a built-in class for java.sql.Timestamp ala below

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;
}

}

RuedigerMoeller commented 6 years ago

You can provide a pull request.