Added support for Date fields.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2947 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
//
|
||||
// $Id: FieldMarshaller.java,v 1.5 2003/07/11 01:22:16 ray Exp $
|
||||
// $Id: FieldMarshaller.java,v 1.6 2004/02/03 15:02:13 mdb Exp $
|
||||
|
||||
package com.threerings.io;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.threerings.presents.Log;
|
||||
@@ -242,6 +243,18 @@ public abstract class FieldMarshaller
|
||||
out.writeUTF((String)field.get(source));
|
||||
}
|
||||
});
|
||||
_marshallers.put(Date.class, new FieldMarshaller() {
|
||||
public void readField (
|
||||
Field field, Object target, ObjectInputStream in)
|
||||
throws Exception {
|
||||
field.set(target, new Date(in.readLong()));
|
||||
}
|
||||
public void writeField (
|
||||
Field field, Object source, ObjectOutputStream out)
|
||||
throws Exception {
|
||||
out.writeLong(((Date)field.get(source)).getTime());
|
||||
}
|
||||
});
|
||||
|
||||
// create field marshallers for all of the basic types
|
||||
int bscount = BasicStreamers.BSTREAMER_TYPES.length;
|
||||
|
||||
Reference in New Issue
Block a user