File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.util.Date setTime() API gives error

 
Celina Joseph
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am passing a long value to the java.util.Date API -
setTime()
It gives me error - "integer number too large."
The API signature is -
public void setTime(long time)
It is expecting a long, but I do not understand on passing a valid long value, it gives me error saying the integer value is too large.
Please let me know what is happening here.
Thanks
 
Michael Morris
Ranch Hand
Posts: 3451
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Celina,
You're gonna have to show us some code or at least the exception's stack trace before we can help you here.
Michael Morris
 
Celina Joseph
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code sample is -
Date dtt = new Date();
dtt.setTime(10480291150);
And the error that I got is -
C:\perso\SampleCode>javac TestUTCDate.java
TestUTCDate.java:14: integer number too large: 10480291150
dtt.setTime(10480291150);
^
1 error
 
Michael Morris
Ranch Hand
Posts: 3451
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Celina,
Oh! A compiler error!. Just add the letter L after your value: date.setTime(10480291150L) and it should work. All integral values are interpreted by the compiler as int unless you specify otherwise.
Michael Morris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic