A date represents an instant in time. A client will represent that in different ways, depending on the local timezone. Whether a particular instant is on May 20 or May 21 depends on your timezone.
Also: (a) A date serialized by GWT does not record its timezone, only the instant in time it refers to (number of millis since Jan 1, 1970) (b) javascript has no timezone manipulation - you can ask a date what it's timezone offset is, but you can't change it. You can build a date from the year/month/date etc or from the number of millis since 1970, but you can't choose what timezone that date belongs to. When you want a date of "May 20, 2010" to be exactly that, regardless of the timezone of the computer on which the date was created, the options I can see are: (1) Tell the server what your timezone is, so it knows how to interpret dates you send to the server. This is not quite as simple as it may sound because a client's timezone changes with daylight savings. Also, you'll have to change the dates you send out to the client so that when they are interpreted by the client, they end up showing the right date/time. (2) Send year/month/date/hour/minute separately over rpc and reconstitute the date from that. HTH Paul Zé Vicente wrote: > Hello all, > > I am having a very bad time with Dates on my GWT application. Can you > please help me? > > The scenario: > 1. The client is on TimeZone A > 2. Server is on TimeZone B > > When the user provides a date on my application, I send the date to > the server using RPC. Then, on the server side, the date is serialized > by with ONE DAY LESS. > > Ex: The user types 21-may-2010. Then on the server, I get 20-may-2010. > > This is not happening to all users. Just the ones with different > timezones from the server. > > How can I fix this? > > Thank you! > José Vicente > > -- 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.
