From 1da661731fb85c73cf68255283d085ada4b5aec2 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 3 Feb 2004 15:02:13 +0000 Subject: [PATCH] Added support for Date fields. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2947 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/java/com/threerings/io/FieldMarshaller.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/io/FieldMarshaller.java b/src/java/com/threerings/io/FieldMarshaller.java index cab1af831..311542fae 100644 --- a/src/java/com/threerings/io/FieldMarshaller.java +++ b/src/java/com/threerings/io/FieldMarshaller.java @@ -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;