Hi,

I just wanted to add to method (1), that sometimes it's not only not
so easy, but even impossible to do such a conversion - because for
most timezones, there are some datetimes which simply don't exist
(when daylight saving occurs).

So I'd definitely recommend (2) - if you don't want to use a special
object, the date can also be stored and transmitted e.g. as an ISO
datetime string (so it's also easier to simply write it in a database
- keep in mind, that you don't have a DATE here (as in ms since
1970-01-01), so probably a DATE column would be wrong anyway).

Ah yes, Paul already said that, but before making any changes, make
sure that you really want a datetime without Timezone. A datetime with
timezone must be treated in a completely different way (in that case,
it's mostly about representation of a point in time in the user's
format and timezone).

Chris

PS
Ideally we'd have Joda time for GWT with its LocalDateTime. I think
there's Goda time, but I haven't really checked it out yet, and I
don't know how much this library will increase code download size (?)
- I'd prefer to have the old Java dates replaced completely by Joda.


On Mar 1, 2:43 pm, Paul Robinson <[email protected]> wrote:
> 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.

Reply via email to