Re: Very strange long assignment issue

2011-02-25 Thread Hilco Wijbenga
On 25 February 2011 15:06, shahid shahidza...@gmail.com wrote:
 I have the following piece of test code in my application (using GWT
 2.1.0):

                        Date expiry = new Date();
                        long expiryTime  = expiry.getTime();
                        expiryTime = expiryTime +  (1000 * 60 * 60 * 24 * 90); 
 // 90 days

This statement is your problem. The (1000 * ... * 90) part is still
using int arithmetic and results in -813934592. Change it to something
like

expiryTime = expiryTime +  (1000L * 60 * 60 * 24 * 90); // 90 days
[Note that it's now 1000L instead of 1000.]

Now the whole (1000L * ... * 90) will use long arithmetic instead of
int and you'll get the correct result.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Very strange long assignment issue

2011-02-25 Thread shahid
Thanks Hilco.

On Feb 25, 5:33 pm, Hilco Wijbenga hilco.wijbe...@gmail.com wrote:
 On 25 February 2011 15:06, shahid shahidza...@gmail.com wrote:

  I have the following piece of test code in my application (using GWT
  2.1.0):

                         Date expiry = new Date();
                         long expiryTime  = expiry.getTime();
                         expiryTime = expiryTime +  (1000 * 60 * 60 * 24 * 
  90); // 90 days

 This statement is your problem. The (1000 * ... * 90) part is still
 using int arithmetic and results in -813934592. Change it to something
 like

 expiryTime = expiryTime +  (1000L * 60 * 60 * 24 * 90); // 90 days
 [Note that it's now 1000L instead of 1000.]

 Now the whole (1000L * ... * 90) will use long arithmetic instead of
 int and you'll get the correct result.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.