Giving wrong value for Date of month

59 views
Skip to first unread message

andy

unread,
Apr 23, 2011, 2:14:09 PM4/23/11
to Google Web Toolkit
int startMonth = startDate.getMonth();
int endMonth = endDate.getMonth();
giving wrong value ....
what to do now?

Gilles B

unread,
Apr 24, 2011, 10:29:03 AM4/24/11
to Google Web Toolkit
It seems to work perfectly, but what is the gwt version, the
application context, the browser, the date object (java.util) ?
Don't forget java Date Month start from 0 (January) to 11 (december).

Date today = new Date();
GWTLog.debug("Today month is "+today.getMonth());
// Display "Today month is 3" => April

On 23 avr, 20:14, andy <andy.anand1...@gmail.com> wrote:
> intstartMonth=startDate.getMonth();

Richard

unread,
Apr 25, 2011, 1:24:02 AM4/25/11
to Google Web Toolkit
You aren't saying what the type is for startDate and endDate.
If they are java.util.Date, I suggest looking ate the javadoc b/c the
method returns 0-11 and is also deprecated.

Richard

mdwarne

unread,
Apr 25, 2011, 10:20:32 PM4/25/11
to Google Web Toolkit
Don't forget the timezone setting of your client PC's if you are using
java.util.Date objects.
Specifically if you send a date object from a client, to the server,
the date may not be what expected, unless you convert your dates to
UTC timezone first, and then convert to your server's timezone.

I had problems with some user's dates being stored in a server
database, being one day off because some client PC's had messed up
timezone or daylight savings settings.

I changed my code to pass String representations of dates to the
server instead of using java.util.Date with RPC.


Mike.
Reply all
Reply to author
Forward
0 new messages