Wednesday, December 1, 2010

Re: CalendarUtil - Unusual Calculation

So the problem won't be inside the CalendarUtil.

Simply put, the following show the same result.

java.util.Date date = new java.util.Date(2010 -1900,12-1,31);
System.out.println(date.toString());
date.setMonth(8);
System.out.println(date.toString());

(I am thinking timezones etc etc.. something smells fishy).

On Dec 1, 10:24 am, Ramon Buckland <ra...@thebuckland.com> wrote:
> Hi
>
> Before I log a bug, I just want to check I am not missing something
> regarding the CalendarUtil.
>
> I have a simple use case that is proving to show an unexpected result.
>
> In Eclipse, open up a Scrapbook page
> and copy the following code in and run it.
>
> java.util.Date calcDate = new java.util.Date(2010 -1900,12-1,31);
> System.out.println(":: b4 -3 months - " + calcDate.toString());
> com.google.gwt.user.datepicker.client.CalendarUtil.addMonthsToDate(calcDate,
> -3);
> System.out.println("::    -3 months - " + calcDate.toString())
>
> I get this output:
>
> :: b4 -3 months - Fri Dec 31 00:00:00 GMT 2010
> ::    -3 months - Fri Oct 01 00:00:00 BST 2010
>
> Which is NOT what I was expecting.
>
> thoughts ?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment