The issue here is that you don't seem to like the established behavior of dates.
This is not a GWT issue, but rather the well known behavior of dates in general. If you don't want date behavior, then use a format that doesn't exhibit this behavior (Strings tend to work nicely). -jason On Oct 17, 2008, at 3:44 PM, sim123 wrote: > > Thanks for response Jason but what about dates, I am setting my > birhtday as today's date and somebody who is in different timezone, > GWT does conversion of birthdate (one day ahead or one day late), for > example if you set any date to be 10-15-2008 you will see same date as > either 10-14-2008 or 10-13-2008 respective to the server's time zone, > is it expected!! > > Another case is I sent an invite saying come to my home this monday at > 4:00 pm, if you are in different time zone you will see same thing as > come to my home on this Monday at 7:00 pm (as GWT did Time > conversion), is it expected too!! > > I think this is the data which is being converted and any program > should not play with user's data, GWT is doing this conversion then to > without any documentation, even if it is expected behavior, it should > be documented and there should be some way to disable this auto > conversion. I don't think passing Strings back and forth would be a > good idea, if I have Date object inside a map/list i need to traverse > through that list/map convert this date into String and return it to > client where client does same thing again, I can not construct a > String right from the beginning as database is returning me Date and > there could be so many different problems with different approaches, I > would prefer to write my own custom serializers in this case, can you > or anyone please tell me what is the problem with the serializer I > mentioned in my previous post? > > Thanks > > On Oct 18, 9:08 am, Jason Essington <[EMAIL PROTECTED]> wrote: >> Of course this is expected behavior! When you are talking about time, >> that time is relative to your location. Just because it is noon where >> you are, doesn't mean it is noon where I am. >> >> If you are in New York, and post a schedule to your server that >> indicates that you will be having a conference call at 4pm, when your >> associate in LA pulls up the schedule, you don't want it to say 4pm, >> you want it to say Noon, otherwise you'll miss each other by 4 hours. >> And what about your partners in India? you don't want them to have to >> guess at what time zone you set that schedule in, then try to figure >> the offset on their own. >> >> If you don't want to take into account timezones when passing date/ >> time back and forth between the server, simply serialize the data >> yourself to something that doesn't include time zones ... like a >> string "Jan 28, 2008 1:45pm" >> >> -jason >> >> On Oct 17, 2008, at 12:56 PM, sim123 wrote: >> >> >> >>> Oh!! so no one knows is it the expected behavior? Or it could be >>> changed? Can any one please suggest that creating custom serializers >>> for java classes is a good idea or not and what could be the pros >>> and >>> cons of this approach? >> >>> Thanks. >> >>> On Oct 18, 5:46 am, "Manuel Carrasco" <[EMAIL PROTECTED]> >>> wrote: >>>> I had the same problem passing java.util.Date from client to >>>> server. When >>>> they use different TZ, dates differ. Eventually I use String >>>> representation >>>> of the dates for client/server dialog, and use DateTimeFormat for >>>> transformations. >> >>>> On Fri, Oct 17, 2008 at 6:36 PM, Tahir Akhtar >>>> <[EMAIL PROTECTED]>wrote: >> >>>>> There is another issue related to serialization of dates that can >>>>> occur due to emulation of long with double in generated >>>>> JavaScript. >> >>>>> See: >> >>>>> http://groups.google.com/group/Google-Web-Toolkit/browse_thread/threa >>>>> ... >> >>>>> On Oct 17, 2:57 am, sim123 <[EMAIL PROTECTED]> wrote: >>>>>> Can some one please reply to my post, please!!! >>>>>> I just want to know if it is expected behavior, and if it is >>>>>> can I >>>>>> create custom serializer for not doing this conversion for >>>>>> example I >>>>>> tried changing Date_CustomFieldSerializer .java's code in to GWT >>>>>> source to be >> >>>>>> public static void deserialize(SerializationStreamReader >>>>>> streamReader, >>>>>> Date instance) { >>>>>> // No fields >>>>>> } >> >>>>>> public static Date instantiate(SerializationStreamReader >>>>>> streamReader) >>>>>> throws SerializationException { >>>>>> Date d = Date.valueOf(streamReader.readString()); >>>>>> return d; >>>>>> } >> >>>>>> public static void serialize(SerializationStreamWriter >>>>>> streamWriter, >>>>>> Date instance) throws SerializationException { >>>>>> streamWriter.writeString(instance.toString()); >>>>>> } >> >>>>>> and it worked, it is not doing any conversion for Date, however I >>>>>> don't want to play with real GWT's code so just wondering if I >>>>>> could >>>>>> write custom serializer for java fields? >> >>>>>> I would really appreciate any help. Thanks >> >>>>>> On Oct 16, 8:28 pm, sim123 <[EMAIL PROTECTED]> wrote: >> >>>>>>> I looked into serialization code for Date/Time and Timestamp in >>>>>>> com.google.gwt.user.client.rpc.core.java.sql package, it seems >>>>>>> that >>>>>>> these classes are cause of time zone conversion, is that so and >>>>>>> is it >>>>>>> expected behavior?? Some one please help me. >> >>>>>>> Thanks. >> >>>>>>> On Oct 16, 6:21 pm, sim123 <[EMAIL PROTECTED]> wrote: >> >>>>>>>> Hello, >> >>>>>>>> I noticed strange behavior of GWT serialization when handling >>>>>>>> Date/ >>>>>>>> Time/Timestamp values. When client and servers are in different >>>>>>>> time >>>>>>>> zones like server is in GMT and client is running in PST time >>>>>>>> zone, >>>>>>>> RPC does timezone conversion for Date/Time and Timestamp, I am >>>>>>>> not >>>>>>>> sure if this is acceptable behavior and if it is then is there >>>>>>>> a way >>>>> I >>>>>>>> could disable this conversion. Here is the example >>>>>>>> public class DateTest implements EntryPoint { >> >>>>>>>> public void onModuleLoad() { >> >>>>>>>> Button b = new Button(); >> >>>>>>>> b.addClickListener(new ClickListener() { >> >>>>>>>> public void onClick(Widget sender) { >>>>>>>> DateServiceAsync dateService = >>>>> DateService.Util.getInstance(); >>>>>>>> dateService.getTimestamp(new >>>>> AsyncCallback<Timestamp>(){ >> >>>>>>>> public void >>>>> onFailure(Throwable caught) { >>>>>>>> // TODO >>>>> Auto-generated method stub >> >>>>>>>> } >> >>>>>>>> public void >>>>> onSuccess(Timestamp result) { >>>>>>>> TextBox tBox = >>>>>>>> new >>>>> TextBox(); >> >>>>> tBox.setText(result.toString()); >> >>>>> RootPanel.get().add(tBox); >>>>>>>> } >> >>>>>>>> }); >>>>>>>> } >> >>>>>>>> }); >>>>>>>> RootPanel.get().add(b); >> >>>>>>>> } >> >>>>>>>> Service Implementation >> >>>>>>>> public class DateServiceImpl extends RemoteServiceServlet >>>>>>>> implements >>>>>>>> DateService { >> >>>>>>>> public Timestamp getTimestamp() { >>>>>>>> Timestamp t = new >>>>> Timestamp(System.currentTimeMillis()); >>>>>>>> System.out.println("timestamp at server" + t); >>>>>>>> return t; >>>>>>>> } >> >>>>>>>> If server is running on GMT Time and client browser is in >>>>>>>> different >>>>>>>> timezone GWT does conversion (even for Date and Time types). >>>>>>>> Please suggest. Thansk for all the help and support. > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. 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 -~----------~----~----~----~------~----~------~--~---
