Have you implemented the custom date serializer noted in this post? It 
worked for me when there was a timezone issue between clients and servers 
being in different regions.


http://code.google.com/p/google-web-toolkit/issues/detail?id=5886

Here is my implementation of that solution. Note that I don't bother 
passing any thing less than seconds. If you don't need seconds you can save 
some space there too over the wire by removing them.

package com.google.gwt.user.client.rpc.core.java.util;

import java.util.Date;

import com.google.gwt.user.client.rpc.CustomFieldSerializer;
import com.google.gwt.user.client.rpc.SerializationException;
import com.google.gwt.user.client.rpc.SerializationStreamReader;
import com.google.gwt.user.client.rpc.SerializationStreamWriter;

public final class Date_CustomFieldSerializer extends 
CustomFieldSerializer<java.util.Date> {

    public static void deserialize(SerializationStreamReader streamReader, 
Date instance) {
        // No fields
    }

    @SuppressWarnings("deprecation")
public static Date instantiate(SerializationStreamReader streamReader) 
throws SerializationException {
        return new Date(
        streamReader.readInt(),
        streamReader.readInt(),
        streamReader.readInt(),
        streamReader.readInt(),
        streamReader.readInt(),
        streamReader.readInt());
    }

    @SuppressWarnings("deprecation")
public static void serialize(SerializationStreamWriter streamWriter, Date 
instance) throws SerializationException {
        streamWriter.writeInt(instance.getYear());
        streamWriter.writeInt(instance.getMonth());
        streamWriter.writeInt(instance.getDate());
        streamWriter.writeInt(instance.getHours());
        streamWriter.writeInt(instance.getMinutes());
        streamWriter.writeInt(instance.getSeconds());
    }

    public void deserializeInstance(SerializationStreamReader streamReader, 
Date instance)
            throws SerializationException {
        deserialize(streamReader, instance);
    }

    @Override
    public boolean hasCustomInstantiateInstance() {
        return true;
    }

    @Override
    public Date instantiateInstance(SerializationStreamReader streamReader) 
throws SerializationException {
        return instantiate(streamReader);
    }

    public void serializeInstance(SerializationStreamWriter streamWriter, 
Date instance) throws SerializationException {
        serialize(streamWriter, instance);
    }

}


Sincerely,
Joseph

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/Rgtr_0BZqaAJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to