Date in GWT

Once more about date and its usage…

In client-server application client send date to server using own TimeZone. So server receives client date and it will manipulate this client date. Sometimes it is not suitable. For example in applications, which is based on server date. So client should be also based on server date.

GWT application is very similar on client desktop applications, because JavaScript code is executed on client side. So by default GWT application uses client date.

Solution is simple we should convert client date to server date. We may do it on client or server side. I selected client side.

Server TimeZone

First, we need to receive server time zone. For this I have created simple service:

with realization:

Note that it returns time zone offset in minutes (GWT time zone offset is based on minutes).

Date Utilities

Now let’s create small utilities class, which will be responsible for converting date from client date to server and vice versa:

Don’t worry that here I have used deprecated methods of Date class – they are working fine in GWT.


And now before sending date on server I should convert date to server date: